Don't create thumbnail images larger than the image; use the source image
authorBrion Vibber <brion@users.mediawiki.org>
Thu, 29 Apr 2004 04:42:52 +0000 (04:42 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Thu, 29 Apr 2004 04:42:52 +0000 (04:42 +0000)
itself if asked. Reject attempts at zero or negative-width thumbs.

includes/Image.php

index 27ad21e..ed69912 100644 (file)
@@ -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) ) ) {