From f7145bfdc4bbfd22085ad98ad12acabf382a5d48 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Mon, 4 Jul 2005 19:20:53 +0000 Subject: [PATCH] * (bug 2632) Fix proportional image scaling, giving correct height * (bug 2640) Include width and height attributes on unscaled images --- RELEASE-NOTES | 3 ++- includes/Linker.php | 19 ++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index a3f1b29f13..fce857208d 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -464,9 +464,10 @@ of MediaWiki:Newpagetext) to &action=edit, if page is new. * (bug 923) Fix title and subtitle for rclinked special page * (bug 2642) watchdetails message in several languages used instead of [ ] * (bug 2181) basic CSB language localisation by Tomasz G. Sienicki (thanks for the patch) -* (bug 2632) also adjust height when zooming an image by giving only width * Fix correct use of escaping in edit toolbar bits * Removed language conversion support from Icelandic +* (bug 2632) Fix proportional image scaling, giving correct height +* (bug 2640) Include width and height attributes on unscaled images === Caveats === diff --git a/includes/Linker.php b/includes/Linker.php index 47a66dc18e..88cb3f214b 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -377,6 +377,8 @@ class Linker { $url = $img->getViewURL(); $prefix = $postfix = ''; + wfDebug( "makeImageLinkObj: '$width'x'$height'\n" ); + if ( 'center' == $align ) { $prefix = '
'; @@ -421,13 +423,24 @@ class Linker { if ( $manual_thumb == '') { $thumb = $img->getThumbnail( $width ); if ( $thumb ) { - // $height = $thumb->height; - $height = floor($thumb->height * $width / $img->width); - $url = $thumb->getUrl( ); + if( $width > $thumb->width ) { + // Requested a display size larger than the actual image; + // fake it up! + $height = floor($thumb->height * $width / $thumb->width); + wfDebug( "makeImageLinkObj: client-size height set to '$height'\n" ); + } else { + $height = $thumb->height; + wfDebug( "makeImageLinkObj: thumb height set to '$height'\n" ); + } + $url = $thumb->getUrl(); } } + } else { + $width = $img->width; + $height = $img->height; } + wfDebug( "makeImageLinkObj2: '$width'x'$height'\n" ); $u = $nt->escapeLocalURL(); if ( $url == '' ) { $s = $this->makeBrokenImageLinkObj( $img->getTitle() ); -- 2.20.1