diff options
Diffstat (limited to 'includes/media/SVG.php')
-rw-r--r-- | includes/media/SVG.php | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/includes/media/SVG.php b/includes/media/SVG.php index 9a8484f1..a78be952 100644 --- a/includes/media/SVG.php +++ b/includes/media/SVG.php @@ -49,14 +49,23 @@ class SvgHandler extends ImageHandler { if ( !parent::normaliseParams( $image, $params ) ) { return false; } - # Don't make an image bigger than wgMaxSVGSize + # Don't make an image bigger than wgMaxSVGSize on the smaller side $params['physicalWidth'] = $params['width']; $params['physicalHeight'] = $params['height']; - if ( $params['physicalWidth'] > $wgSVGMaxSize ) { - $srcWidth = $image->getWidth( $params['page'] ); - $srcHeight = $image->getHeight( $params['page'] ); - $params['physicalWidth'] = $wgSVGMaxSize; - $params['physicalHeight'] = File::scaleHeight( $srcWidth, $srcHeight, $wgSVGMaxSize ); + if ( $params['physicalWidth'] <= $params['physicalHeight'] ) { + if ( $params['physicalWidth'] > $wgSVGMaxSize ) { + $srcWidth = $image->getWidth( $params['page'] ); + $srcHeight = $image->getHeight( $params['page'] ); + $params['physicalWidth'] = $wgSVGMaxSize; + $params['physicalHeight'] = File::scaleHeight( $srcWidth, $srcHeight, $wgSVGMaxSize ); + } + } else { + if ( $params['physicalHeight'] > $wgSVGMaxSize ) { + $srcWidth = $image->getWidth( $params['page'] ); + $srcHeight = $image->getHeight( $params['page'] ); + $params['physicalWidth'] = File::scaleHeight( $srcHeight, $srcWidth, $wgSVGMaxSize ); + $params['physicalHeight'] = $wgSVGMaxSize; + } } return true; } |