* More scary link caching modes
* Old manually maintained log pages replaced with searchable Special:Log
* Skins system more modular: templates and CSS are now in /skins/
+* New user preference for limitting the image size for images on image description
+ pages
* ... and more!
=== Caveats ===
* Load the revision (including cur_text) into this object
*/
function loadContent( $noredir = false ) {
- global $wgOut, $wgMwRedir, $wgRequest;
+ global $wgOut, $wgRequest;
$dbr =& $this->getDB();
# Query variables :P
#
$wgUseImageResize = false;
-## Set maximum width of images on image description pages.
-## Images bigger than this will be rendered down.
-$wgMaxImageWidth = 800;
-
## Resizing can be done using PHP's internal image libraries
## or using ImageMagick. The later supports more file formats
## than PHP, which only supports PNG, GIF, JPG, XBM and WBMP.
# If unsure, set to false.
$wgEnableSOAP = false;
+# Limit images on image description pages to a user-selectable limit. In order to
+# reduce disk usage, limits can only be selected from a list. This is the list of
+# settings the user can choose from:
+$wgImageLimits = array (
+ array(320,240),
+ array(640,480),
+ array(800,600),
+ array(1024,768),
+ array(1280,1024),
+ array(10000,10000) );
+
} else {
die();
}
return $this->height;
}
+ function getSize()
+ {
+ $st = stat( $this->getImagePath() );
+ return $st['size'];
+ }
+
function getType()
{
return $this->type;
function openShowImage()
{
- global $wgOut, $wgUser, $wgRequest, $wgMaxImageWidth, $wgUseImageResize;
+ global $wgOut, $wgUser, $wgImageLimits, $wgRequest, $wgUseImageResize;
$this->img = Image::newFromTitle( $this->mTitle );
$url = $this->img->getUrl();
$anchoropen = '';
$anchorclose = '';
+ if ( $wgUseImageResize && $wgUser->getOption( 'imagesize' ) != '' ) {
+ $max = $wgImageLimits[ intval( $wgUser->getOption( 'imagesize' ) ) ];
+ $maxWidth = $max[0];
+ $maxHeight = $max[1];
+ }
if ( $this->img->exists() ) {
# image
$width = $this->img->getWidth();
$height = $this->img->getHeight();
- if ( $width > $wgMaxImageWidth && $wgUseImageResize ) {
+ if ( $width > $maxWidth && $wgUseImageResize ) {
+ $msg = wfMsg('showbigimage', $width, $height, intval( $this->img->getSize()/1024 ) );
+ $anchoropen = "<a href=\"{$url}\">";
+ $anchorclose = "<br>{$msg}</a>";
+
+ $url = $this->img->createThumb( $maxWidth );
+ $height = floor( $height * $maxWidth / $width );
+ $width = $maxWidth;
+ } elseif ( $height > $maxHeight && $wgUseImageResize ) {
+ $msg = wfMsg('showbigimage', $width, $height, intval( $this->img->getSize()/1024 ) );
$anchoropen = "<a href=\"{$url}\">";
- $anchorclose = '</a>';
- $url=$this->img->createThumb( $wgMaxImageWidth );
- $height = floor( $height * $wgMaxImageWidth / $width );
- $width = $wgMaxImageWidth;
+ $anchorclose = "<br>{$msg}</a>";
+
+ $width = floor( $width * $maxHeight / $height );
+ $height = $maxHeight;
+ $url = $this->img->createThumb( $width );
}
- $s = "<div class=\"fullImage\">" . $anchoropen .
+ $s = "<div class=\"fullImageLink\">" . $anchoropen .
"<img border=\"0\" src=\"{$url}\" width=\"{$width}\" height=\"{$height}\" alt=\"" .
$wgRequest->getVal( 'image' )."\" />" . $anchorclose . "</div>";
} else {
var $mRows, $mCols, $mSkin, $mMath, $mDate, $mUserEmail, $mEmailFlag, $mNick;
var $mUserLanguage;
var $mSearch, $mRecent, $mHourDiff, $mSearchLines, $mSearchChars, $mAction;
- var $mReset, $mPosted, $mToggles, $mSearchNs, $mRealName;
+ var $mReset, $mPosted, $mToggles, $mSearchNs, $mRealName, $mImageSize;
/**
* Constructor
$this->mHourDiff = $request->getVal( 'wpHourDiff' );
$this->mSearchLines = $request->getVal( 'wpSearchLines' );
$this->mSearchChars = $request->getVal( 'wpSearchChars' );
+ $this->mImageSize = $request->getVal( 'wpImageSize' );
+
$this->mAction = $request->getVal( 'action' );
$this->mReset = $request->getCheck( 'wpReset' );
$this->mPosted = $request->wasPosted();
$wgUser->setOption( 'cols', $this->validateInt( $this->mCols, 4, 1000 ) );
$wgUser->setOption( 'stubthreshold', $this->validateIntOrNull( $this->mStubs ) );
$wgUser->setOption( 'timecorrection', $this->validateTimeZone( $this->mHourDiff, -12, 14 ) );
+ $wgUser->setOption( 'imagesize', $this->mImageSize );
# Set search namespace options
foreach( $this->mSearchNs as $i => $value ) {
$this->mSearch = $wgUser->getOption( 'searchlimit' );
$this->mSearchLines = $wgUser->getOption( 'contextlines' );
$this->mSearchChars = $wgUser->getOption( 'contextchars' );
+ $this->mImageSize = $wgUser->getOption( 'imagesize' );
$this->mRecent = $wgUser->getOption( 'rclimit' );
$togs = $wgLang->getUserToggles();
*/
function mainPrefsForm( $err ) {
global $wgUser, $wgOut, $wgLang, $wgUseDynamicDates, $wgValidSkinNames;
- global $wgAllowRealName;
+ global $wgAllowRealName, $wgImageLimits;
$wgOut->setPageTitle( wfMsg( 'preferences' ) );
$wgOut->setArticleRelated( false );
" . $this->getToggle( "hideminor" ) .
$this->getToggle( "usenewrc" ) . "
<div><label>$stt: <input type='text' name=\"wpStubs\" value=\"$this->mStubs\" size='6' /></label></div>
+ <div><label>".wfMsg('imagemaxsize')."<select name=\"wpImageSize\">");
+
+ $imageLimitOptions='';
+ foreach ( $wgImageLimits as $index => $limits ) {
+ $selected = ($index == $this->mImageSize) ? ' selected ': '';
+ $imageLimitOptions .= "<option value=\"{$index}\" {$selected}>{$limits[0]}x{$limits[1]}</option>\n";
+ }
+ $wgOut->addHTML( "{$imageLimitOptions}</select></label></div>
+
</fieldset>
<fieldset>
'highlightbroken' => 1, 'stubthreshold' => 0,
'previewontop' => 1, 'editsection'=>1,'editsectiononrightclick'=>0, 'showtoc'=>1,
'showtoolbar' =>1,
- 'date' => 0
+ 'date' => 0, 'imagesize' => 2
);
/* private */ $wgQuickbarSettingsEn = array(
'previousdiff' => '← Go to previous diff',
'nextdiff' => 'Go to next diff →',
+'imagemaxsize' => 'Limit images on image description pages to: ',
+'showbigimage' => 'Download high resolution version ($1x$2, $3 KB)',
+
);