Merge "API: Fix imageinfo iiurlheight on audio files"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Mon, 24 Jun 2013 17:15:43 +0000 (17:15 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Mon, 24 Jun 2013 17:15:43 +0000 (17:15 +0000)
includes/api/ApiQueryImageInfo.php

index 4849f40..fedf860 100644 (file)
@@ -231,10 +231,18 @@ class ApiQueryImageInfo extends ApiQueryBase {
         * @return Array of parameters for transform.
         */
        protected function mergeThumbParams( $image, $thumbParams, $otherParams ) {
+               global $wgThumbLimits;
 
                if ( !isset( $thumbParams['width'] ) && isset( $thumbParams['height'] ) ) {
-                       // Populate the width with the image's width, so only the height restriction applies
-                       $thumbParams['width'] = $image->getWidth();
+                       // We want to limit only by height in this situation, so pass the
+                       // image's full width as the limiting width. But some file types
+                       // don't have a width of their own, so pick something arbitrary so
+                       // thumbnailing the default icon works.
+                       if ( $image->getWidth() <= 0 ) {
+                               $thumbParams['width'] = max( $wgThumbLimits );
+                       } else {
+                               $thumbParams['width'] = $image->getWidth();
+                       }
                }
 
                if ( !$otherParams ) {