#
$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.
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() ) {
if ( $this->img->getType() != "" ) {
# image
- $s = "<div class=\"fullImage\">" .
- "<img src=\"{$url}\" width=\"" . $this->img->getWidth() . "\" height=\"" . $this->img->getHeight() .
- "\" alt=\"".$wgRequest->getVal( 'image' )."\" /></div>";
+ $width = $this->img->getWidth();
+ $height = $this->img->getHeight();
+ if ( $width > $wgMaxImageWidth && $wgUseImageResize ) {
+ $anchoropen = "<a href=\"{$url}\">";
+ $anchorclose = '</a>';
+ $url=$this->img->createThumb( $wgMaxImageWidth );
+ $height = floor( $height * $wgMaxImageWidth / $width );
+ $width = $wgMaxImageWidth;
+ }
+ $s = "<div class=\"fullImage\">" . $anchoropen .
+ "<img border=\"0\" src=\"{$url}\" width=\"{$width}\" height=\"{$height}\" alt=\"" .
+ $wgRequest->getVal( 'image' )."\" />" . $anchorclose . "</div>";
} else {
$s = "<div class=\"fullMedia\">".$sk->makeMediaLink($this->img->getName(),"")."</div>";
}