* (bug 2632) Fix proportional image scaling, giving correct height
authorBrion Vibber <brion@users.mediawiki.org>
Mon, 4 Jul 2005 19:20:53 +0000 (19:20 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Mon, 4 Jul 2005 19:20:53 +0000 (19:20 +0000)
* (bug 2640) Include width and height attributes on unscaled images

RELEASE-NOTES
includes/Linker.php

index a3f1b29..fce8572 100644 (file)
@@ -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  <a></a> 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 ===
index 47a66dc..88cb3f2 100644 (file)
@@ -377,6 +377,8 @@ class Linker {
                $url   = $img->getViewURL();
                $prefix = $postfix = '';
                
+               wfDebug( "makeImageLinkObj: '$width'x'$height'\n" );
+               
                if ( 'center' == $align )
                {
                        $prefix  = '<div class="center">';
@@ -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() );