From 2ae2c36154590167f2e1c6bc9823a881f13389e9 Mon Sep 17 00:00:00 2001 From: jarry1250 Date: Sat, 1 Sep 2012 17:12:48 +0100 Subject: [PATCH] Convert core to use new ThumbnailImage() constructor See change #21321 for the introduction of that new constructor and the reasoning behind it. Change-Id: I15843fab4217333077e16ae187e7c09f76d47e58 --- includes/filerepo/file/File.php | 3 ++- includes/media/Bitmap.php | 25 +++++++++++++++++-------- includes/media/Bitmap_ClientOnly.php | 3 +-- includes/media/DjVu.php | 14 ++++++++++++-- includes/media/ImageHandler.php | 4 +--- includes/media/SVG.php | 4 ++-- 6 files changed, 35 insertions(+), 18 deletions(-) diff --git a/includes/filerepo/file/File.php b/includes/filerepo/file/File.php index 4cc47f0041..3d1e270254 100644 --- a/includes/filerepo/file/File.php +++ b/includes/filerepo/file/File.php @@ -1000,7 +1000,8 @@ abstract class File { $path = '/common/images/icons/' . $icon; $filepath = $wgStyleDirectory . $path; if ( file_exists( $filepath ) ) { // always FS - return new ThumbnailImage( $this, $wgStylePath . $path, 120, 120 ); + $params = array( 'width' => 120, 'height' => 120 ); + return new ThumbnailImage( $this, $wgStylePath . $path, false, $params ); } } return null; diff --git a/includes/media/Bitmap.php b/includes/media/Bitmap.php index 8a4b943271..99ac854ba1 100644 --- a/includes/media/Bitmap.php +++ b/includes/media/Bitmap.php @@ -167,8 +167,11 @@ class BitmapHandler extends ImageHandler { if ( $flags & self::TRANSFORM_LATER ) { wfDebug( __METHOD__ . ": Transforming later per flags.\n" ); - return new ThumbnailImage( $image, $dstUrl, $scalerParams['clientWidth'], - $scalerParams['clientHeight'], false ); + $params = array( + 'width' => $scalerParams['clientWidth'], + 'height' => $scalerParams['clientHeight'] + ); + return new ThumbnailImage( $image, $dstUrl, false, $params ); } # Try to make a target path for the thumbnail @@ -220,8 +223,11 @@ class BitmapHandler extends ImageHandler { } elseif ( $mto ) { return $mto; } else { - return new ThumbnailImage( $image, $dstUrl, $scalerParams['clientWidth'], - $scalerParams['clientHeight'], $dstPath ); + $params = array( + 'width' => $scalerParams['clientWidth'], + 'height' => $scalerParams['clientHeight'] + ); + return new ThumbnailImage( $image, $dstUrl, $dstPath, $params ); } } @@ -258,14 +264,17 @@ class BitmapHandler extends ImageHandler { * client side * * @param $image File File associated with this thumbnail - * @param $params array Array with scaler params + * @param $scalerParams array Array with scaler params * @return ThumbnailImage * * @todo fixme: no rotation support */ - protected function getClientScalingThumbnailImage( $image, $params ) { - return new ThumbnailImage( $image, $image->getURL(), - $params['clientWidth'], $params['clientHeight'], null ); + protected function getClientScalingThumbnailImage( $image, $scalerParams ) { + $params = array( + 'width' => $scalerParams['clientWidth'], + 'height' => $scalerParams['clientHeight'] + ); + return new ThumbnailImage( $image, $image->getURL(), null, $params ); } /** diff --git a/includes/media/Bitmap_ClientOnly.php b/includes/media/Bitmap_ClientOnly.php index 8cb5138367..63af2552c3 100644 --- a/includes/media/Bitmap_ClientOnly.php +++ b/includes/media/Bitmap_ClientOnly.php @@ -52,7 +52,6 @@ class BitmapHandler_ClientOnly extends BitmapHandler { if ( !$this->normaliseParams( $image, $params ) ) { return new TransformParameterError( $params ); } - return new ThumbnailImage( $image, $image->getURL(), $params['width'], - $params['height'], $image->getLocalRefPath() ); + return new ThumbnailImage( $image, $image->getURL(), $image->getLocalRefPath(), $params ); } } diff --git a/includes/media/DjVu.php b/includes/media/DjVu.php index ea4888a9c5..84672e05c4 100644 --- a/includes/media/DjVu.php +++ b/includes/media/DjVu.php @@ -157,7 +157,12 @@ class DjVuHandler extends ImageHandler { } if ( $flags & self::TRANSFORM_LATER ) { - return new ThumbnailImage( $image, $dstUrl, $width, $height, $dstPath, $page ); + $params = array( + 'width' => $width, + 'height' => $height, + 'page' => $page + ); + return new ThumbnailImage( $image, $dstUrl, $dstPath, $params ); } if ( !wfMkdirParents( dirname( $dstPath ), null, __METHOD__ ) ) { @@ -192,7 +197,12 @@ class DjVuHandler extends ImageHandler { wfHostname(), $retval, trim($err), $cmd ) ); return new MediaTransformError( 'thumbnail_error', $width, $height, $err ); } else { - return new ThumbnailImage( $image, $dstUrl, $width, $height, $dstPath, $page ); + $params = array( + 'width' => $width, + 'height' => $height, + 'page' => $page + ); + return new ThumbnailImage( $image, $dstUrl, $dstPath, $params ); } } diff --git a/includes/media/ImageHandler.php b/includes/media/ImageHandler.php index 65757c933d..61759074d8 100644 --- a/includes/media/ImageHandler.php +++ b/includes/media/ImageHandler.php @@ -189,11 +189,9 @@ abstract class ImageHandler extends MediaHandler { return false; } $url = $script . '&' . wfArrayToCGI( $this->getScriptParams( $params ) ); - $page = isset( $params['page'] ) ? $params['page'] : false; if( $image->mustRender() || $params['width'] < $image->getWidth() ) { - return new ThumbnailImage( $image, - $url, $params['width'], $params['height'], false, $page ); + return new ThumbnailImage( $image, $url, false, $params ); } } diff --git a/includes/media/SVG.php b/includes/media/SVG.php index a9d1758b32..55fa5547bf 100644 --- a/includes/media/SVG.php +++ b/includes/media/SVG.php @@ -117,7 +117,7 @@ class SvgHandler extends ImageHandler { $physicalHeight = $params['physicalHeight']; if ( $flags & self::TRANSFORM_LATER ) { - return new ThumbnailImage( $image, $dstUrl, $clientWidth, $clientHeight, $dstPath ); + return new ThumbnailImage( $image, $dstUrl, $dstPath, $params ); } if ( !wfMkdirParents( dirname( $dstPath ), null, __METHOD__ ) ) { @@ -128,7 +128,7 @@ class SvgHandler extends ImageHandler { $srcPath = $image->getLocalRefPath(); $status = $this->rasterize( $srcPath, $dstPath, $physicalWidth, $physicalHeight ); if( $status === true ) { - return new ThumbnailImage( $image, $dstUrl, $clientWidth, $clientHeight, $dstPath ); + return new ThumbnailImage( $image, $dstUrl, $dstPath, $params ); } else { return $status; // MediaTransformError } -- 2.20.1