Page MenuHomePhabricator

SVGs are not resized down properly on image pages
Closed, ResolvedPublic

Description

Author: ejsanders

Description:
SVGs are not resized down to fit on Image: pages. They are rendered at their
normal size, and then placed on the page with the width="800" (or whatever your
setting is) attribute set in the image tag, meaning they are only rescaled by
the browser. This is beacuse mustRender() (Image.php) returns true for SVG,
hoever simply adding "image/SVG" to this list of types that return false in this
function does not fix the problem, as this causes the SVGs to render to the
wrong path.

My hack invovled changing line 171 of ImagePage.php
from:

if ( !$this->img->mustRender() 
     && ( $width != $this->img->getWidth() || $height !=

$this->img->getHeight() ) ) {

to:

if ( (!$this->img->mustRender() || $this->img->getMimeType() == 'image/svg' )
     && ( $width != $this->img->getWidth() || $height !=

$this->img->getHeight() ) ) {

which solves the problem, but is it a bit ugly.


Version: 1.5.x
Severity: normal
URL: http://commons.wikimedia.org/wiki/Image:Bakerloo_Line.svg

Details

Reference
bz3127

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 8:44 PM
bzimport set Reference to bz3127.

I've simply removed the mustRender() check here as it doesn't serve any apparent
purpose.