don't try to prefill edit summary when section=new (relevant only for preload=)
[lhc/web/wiklou.git] / includes / Linker.php
index 47a66dc..76ddde2 100644 (file)
@@ -20,7 +20,7 @@ class Linker {
        function Linker() {}
 
        /**
-        * OBSOLETE
+        * @deprecated
         */
        function postParseLinkColour( $s = NULL ) {
                return NULL;
@@ -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() );
@@ -476,7 +489,7 @@ class Linker {
                        $boxheight = $height;
                        $thumbUrl  = $url;
                } else {
-                       $h  = intval( $height/($width/$boxwidth) );
+                       $h  = round( $height/($width/$boxwidth) );
                        $oboxwidth = $boxwidth + 2;
                        if ( ( ! $boxheight === false ) &&  ( $h > $boxheight ) )
                        {