From: Jens Frank Date: Tue, 17 Aug 2004 21:07:14 +0000 (+0000) Subject: On image pages, limit image width to $wgMaxImageWidth. X-Git-Tag: 1.5.0alpha1~2303 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dmembres/modifier.php?a=commitdiff_plain;h=5f4b3ec0642d1b16524bd614b18a34ca1e6b086a;p=lhc%2Fweb%2Fwiklou.git On image pages, limit image width to $wgMaxImageWidth. If $wgUseImageResize is set, the image will be resized to fit this limit. The resized image links to the big image. Default for $wgMaxImageWidth is 800 pixels. Set to really big values (like 9999999) to disable. --- diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 1375c74587..91b5cb287a 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -392,6 +392,10 @@ $wgSiteNotice = ""; # $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. diff --git a/includes/ImagePage.php b/includes/ImagePage.php index 0d7215c107..9f0eab9758 100644 --- a/includes/ImagePage.php +++ b/includes/ImagePage.php @@ -31,9 +31,12 @@ class ImagePage extends Article { function openShowImage() { - global $wgOut, $wgUser,$wgRequest; + global $wgOut, $wgUser, $wgRequest, $wgMaxImageWidth, $wgUseImageResize; $this->img = Image::newFromTitle( $this->mTitle ); $url = $this->img->getUrl(); + $anchoropen = ""; + $anchorclose = ""; + if ( $this->img->exists() ) { @@ -41,9 +44,18 @@ class ImagePage extends Article { if ( $this->img->getType() != "" ) { # image - $s = "
" . - "img->getWidth() . "\" height=\"" . $this->img->getHeight() . - "\" alt=\"".$wgRequest->getVal( 'image' )."\" />
"; + $width = $this->img->getWidth(); + $height = $this->img->getHeight(); + if ( $width > $wgMaxImageWidth && $wgUseImageResize ) { + $anchoropen = ""; + $anchorclose = ''; + $url=$this->img->createThumb( $wgMaxImageWidth ); + $height = floor( $height * $wgMaxImageWidth / $width ); + $width = $wgMaxImageWidth; + } + $s = "
" . $anchoropen . + "\""getVal( 'image' )."\" />" . $anchorclose . "
"; } else { $s = "
".$sk->makeMediaLink($this->img->getName(),"")."
"; }