From: Brion Vibber Date: Thu, 29 Apr 2004 04:42:52 +0000 (+0000) Subject: Don't create thumbnail images larger than the image; use the source image X-Git-Tag: 1.3.0beta1~202 X-Git-Url: http://git.cyclocoop.org/%22.%24image2.%22?a=commitdiff_plain;h=00e5822e17843fe97169db68ed6076d98c1d46ad;p=lhc%2Fweb%2Fwiklou.git Don't create thumbnail images larger than the image; use the source image itself if asked. Reject attempts at zero or negative-width thumbs. --- diff --git a/includes/Image.php b/includes/Image.php index 27ad21e326..ed69912a61 100644 --- a/includes/Image.php +++ b/includes/Image.php @@ -103,6 +103,17 @@ class Image # If there is no image, there will be no thumbnail return ""; } + + # Sanity check $width + $width = IntVal( $width ); + if( $width <= 0 ) { + # BZZZT + return ""; + } + if( $width > $this->width ) { + # Don't make an image bigger than the source + return $this->getURL(); + } if ( (! file_exists( $thumbPath ) ) || ( filemtime($thumbPath) < filemtime($this->imagePath) ) ) {