From 63ba45b14145c29f58661503defde88b9099f3c3 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 7 Dec 2005 22:57:22 +0000 Subject: [PATCH] * (bug 4207) Wrong image size when using 100x200px syntax to scale image up patch by David Benbennick http://bugzilla.wikimedia.org/attachment.cgi?id=1152 --- RELEASE-NOTES | 2 ++ includes/Linker.php | 21 ++++++++++++--------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 1c1d9906f3..1dad42f567 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -302,6 +302,8 @@ fully support the editing toolbar, but was found to be too confusing. * Avoid FATAL ERROR when creating thumbnail of non-existing image * (bug 4192) Remove silly 'The Free Encyclopedia' default sitesubtitle * (bug 4201) Fix user-talk mode for Enotif, and general code cleanup +* (bug 4207) Wrong image size when using 100x200px syntax to scale image up + patch by David Benbennick === Caveats === diff --git a/includes/Linker.php b/includes/Linker.php index 036b2cc35e..3348c5809d 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -430,16 +430,19 @@ class Linker { if ( $manual_thumb == '') { $thumb = $img->getThumbnail( $width, $height ); if ( $thumb ) { - if( $width > $img->width && ( $height == -1 || $height > $img->height )) { - // Requested a display size larger than the actual image; - // fake it up! - $height = round($thumb->height * $width / $thumb->width); - wfDebug( "makeImageLinkObj: client-size height set to '$height'\n" ); - } else { - $width = $thumb->width; - $height = $thumb->height; - wfDebug( "makeImageLinkObj: thumb height set to '$height'\n" ); + // In most cases, $width = $thumb->width or $height = $thumb->height. + // If not, we're scaling the image larger than it can be scaled, + // so we send to the browser a smaller thumbnail, and let the client do the scaling. + + if ($height != -1 && $width > $thumb->width * $height / $thumb->height) { + // $height is the limiting factor, not $width + // set $width to the largest it can be, such that the resulting + // scaled height is at most $height + $width = floor($thumb->width * $height / $thumb->height); } + $height = round($thumb->height * $width / $thumb->width); + + wfDebug( "makeImageLinkObj: client-size set to '$width x $height'\n" ); $url = $thumb->getUrl(); } } -- 2.20.1