From: Tim Starling Date: Sat, 17 Jun 2006 04:11:21 +0000 (+0000) Subject: Fixed inconsistent error return in Image::getThumbnail() -- was returning null if... X-Git-Tag: 1.31.0-rc.0~56760 X-Git-Url: http://git.cyclocoop.org/%28?a=commitdiff_plain;h=043c6d2c83c82df3ce1450051117ef39879fbdb1;p=lhc%2Fweb%2Fwiklou.git Fixed inconsistent error return in Image::getThumbnail() -- was returning null if height wasn't specified, an icon thumb if it was. Made it return null all the time, and fixed ImageGallery.php to understand that return value. Also made ImageGallery give informative errors if $wgIgnoreImageErrors is off. --- diff --git a/includes/Image.php b/includes/Image.php index 3f5e64242d..0b1d8d6a23 100644 --- a/includes/Image.php +++ b/includes/Image.php @@ -888,7 +888,7 @@ class Image * * @param integer $width maximum width of the generated thumbnail * @param integer $height maximum height of the image (optional) - * @return ThumbnailImage + * @return ThumbnailImage or null on failure * @public */ function getThumbnail( $width, $height=-1 ) { @@ -904,9 +904,6 @@ class Image } else $thumb= NULL; #not a bitmap or renderable image, don't try. - if( is_null( $thumb ) ) { - $thumb = $this->iconThumb(); - } return $thumb; } @@ -936,7 +933,7 @@ class Image * Returns an object which can return the pathname, URL, and physical * pixel size of the thumbnail -- or null on failure. * - * @return ThumbnailImage + * @return ThumbnailImage or null on failure * @private */ function renderThumb( $width, $useScript = true ) { diff --git a/includes/ImageGallery.php b/includes/ImageGallery.php index 08528f50bb..4ae92d0e3f 100644 --- a/includes/ImageGallery.php +++ b/includes/ImageGallery.php @@ -98,7 +98,7 @@ class ImageGallery * */ function toHTML() { - global $wgLang, $wgUser; + global $wgLang, $wgUser, $wgIgnoreImageErrors; $sk = $wgUser->getSkin(); @@ -146,16 +146,29 @@ class ImageGallery $s .= ($i%4==0) ? '' : ''; $thumb = $img->getThumbnail( 120, 120 ); - $vpad = floor( ( 150 - $thumb->height ) /2 ) - 2; - $s .= '
' . '
'; - - # ATTENTION: The newline after
is needed to accommodate htmltidy which - # in version 4.8.6 generated crackpot html in its absence, see: - # http://bugzilla.wikimedia.org/show_bug.cgi?id=1765 -Ævar - $s .= $sk->makeKnownLinkObj( $nt, $thumb->toHtml() ) . '
' . "\n" . - $textlink . $text . $nb . - '
'; - $s .= "
\n"; + if ( !$thumb && $wgIgnoreImageErrors ) { + $thumb = $img->iconThumb(); + } + if ( $thumb ) { + $vpad = floor( ( 150 - $thumb->height ) /2 ) - 2; + $s .= '
' . '
'; + + # ATTENTION: The newline after
is needed to accommodate htmltidy which + # in version 4.8.6 generated crackpot html in its absence, see: + # http://bugzilla.wikimedia.org/show_bug.cgi?id=1765 -Ævar + $s .= $sk->makeKnownLinkObj( $nt, $thumb->toHtml() ) . '
' . "\n" . + $textlink . $text . $nb . + '
'; + $s .= "
\n"; + } else { + # Error during thumbnail generation + $s .= '
' . + #htmlspecialchars( $nt->getText() ) . "
\n" . + htmlspecialchars( $img->getLastError() ) . + "
\n" . + $textlink . $text . $nb . + "
\n"; + } $s .= ($i%4==3) ? '' : ''; $i++; }