From 96d89329f39659351c388974ba0aaf485242517f Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Fri, 5 Sep 2008 04:23:24 +0000 Subject: [PATCH] * Don't force rendering in File::getThumbnail(). The old code (pre-filerepo) required rendering to be forced all the time, the new code is much smarter about when to render and doesn't need rendering to be forced. Forcing rendering causes non-scaler servers to be used for scaling. * Use File::transform() in the core instead of the deprecated File::getThumbnail(). --- includes/api/ApiQueryImageInfo.php | 10 +++++----- includes/filerepo/File.php | 4 +--- includes/specials/SpecialFileDuplicateSearch.php | 2 +- includes/specials/SpecialSearch.php | 2 +- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/includes/api/ApiQueryImageInfo.php b/includes/api/ApiQueryImageInfo.php index 99201e20a7..6f5c5e22e7 100644 --- a/includes/api/ApiQueryImageInfo.php +++ b/includes/api/ApiQueryImageInfo.php @@ -123,12 +123,12 @@ class ApiQueryImageInfo extends ApiQueryBase { } if( isset( $prop['url'] ) ) { if( !is_null( $scale ) && !$file->isOld() ) { - $thumb = $file->getThumbnail( $scale['width'], $scale['height'] ); - if( $thumb ) + $mto = $file->transform( array( 'width' => $scale['width'], 'height' => $scale['height'] ) ); + if( $mto && !$mto->isError() ) { - $vals['thumburl'] = wfExpandUrl( $thumb->getURL() ); - $vals['thumbwidth'] = $thumb->getWidth(); - $vals['thumbheight'] = $thumb->getHeight(); + $vals['thumburl'] = $mto->getUrl(); + $vals['thumbwidth'] = $mto->getWidth(); + $vals['thumbheight'] = $mto->getHeight(); } } $vals['url'] = $file->getFullURL(); diff --git a/includes/filerepo/File.php b/includes/filerepo/File.php index 8ae51f0deb..c22d00d750 100644 --- a/includes/filerepo/File.php +++ b/includes/filerepo/File.php @@ -506,8 +506,7 @@ abstract class File { * * @param integer $width maximum width of the generated thumbnail * @param integer $height maximum height of the image (optional) - * @param boolean $render True to render the thumbnail if it doesn't exist, - * false to just return the URL + * @param boolean $render Deprecated * * @return ThumbnailImage or null on failure * @@ -518,7 +517,6 @@ abstract class File { if ( $height != -1 ) { $params['height'] = $height; } - $flags = $render ? self::RENDER_NOW : 0; return $this->transform( $params, $flags ); } diff --git a/includes/specials/SpecialFileDuplicateSearch.php b/includes/specials/SpecialFileDuplicateSearch.php index 5236ca2519..98454d839e 100644 --- a/includes/specials/SpecialFileDuplicateSearch.php +++ b/includes/specials/SpecialFileDuplicateSearch.php @@ -100,7 +100,7 @@ function wfSpecialFileDuplicateSearch( $par = null ) { # Show a thumbnail of the file $img = wfFindFile( $title ); if ( $img ) { - $thumb = $img->getThumbnail( 120, 120 ); + $thumb = $img->transform( array( 'width' => 120, 'height' => 120 ) ); if( $thumb ) { $wgOut->addHTML( '
' . $thumb->toHtml( array( 'desc-link' => false ) ) . '
' . diff --git a/includes/specials/SpecialSearch.php b/includes/specials/SpecialSearch.php index 815946bf8f..3ee0bf11fa 100644 --- a/includes/specials/SpecialSearch.php +++ b/includes/specials/SpecialSearch.php @@ -448,7 +448,7 @@ class SpecialSearch { if( $t->getNamespace() == NS_IMAGE ) { $img = wfFindFile( $t ); if( $img ) { - $thumb = $img->getThumbnail( 120, 120 ); + $thumb = $img->transform( array( 'width' => 120, 'height' => 120 ) ); if( $thumb ) { $desc = $img->getShortDesc(); wfProfileOut( $fname ); -- 2.20.1