# Check for zero-sized thumbnails. Those can be generated when
# no disk space is available or some other error occurs
#
- if( file_exists( $thumbstat ) ) {
+ if( file_exists( $thumbPath ) ) {
$thumbstat = stat( $thumbPath );
if( $thumbstat['size'] == 0 ) {
unlink( $thumbPath );
$html .= '/>';
return $html;
}
+
+ /**
+ * Return the size of the thumbnail file, in bytes
+ * @access public
+ */
+ function getSize()
+ {
+ $st = stat( $this->path );
+ if( $st ) {
+ return $st['size'];
+ } else {
+ return false; }
+ }
+
}
?>
}
if ( $width != $this->img->getWidth() || $height != $this->img->getHeight() ) {
if( $wgUseImageResize ) {
- $url = $this->img->createThumb( $width );
+ $thumbnail = $this->img->getThumbnail( $width );
+ print "<pre>thumb ". $thumbnail->getSize() ."\nimg ".$this->img->getSize()."</pre>";
+ if ( ( ! $this->img->mustRender() )
+ && ( $thumbnail->getSize() > $this->img->getSize() ) ) {
+ # the thumbnail is bigger thatn the original image.
+ # show the original image instead of the thumb.
+ $url = $full_url;
+ $width = $this->img->getWidth();
+ $height = $this->img->getHeight();
+ } else {
+ $url = $thumbnail->getUrl();
+ }
} else {
# No resize ability? Show the full image, but scale
# it down in the browser so it fits on the page.