Last modified: 2008-12-16 05:46:27 UTC
Images that do not have a width and height attribute are currently rendered to 256x256 pixel. This breaks the aspect ratio for all non-square images, and is also quite small. SVG does not require the width and height attributes to be present, see <http://www.w3.org/TR/SVG/coords.html#ViewportSpace>. If not present, the size to use is to be derived from the document including the SVG. In the case of MediaWiki, this would be the thumbnails size, resp. the size given in the user preferences for the size of images on image description pages. Also, the aspect ratio defined by a viewBox attribute should be honoured, if present. A patch that addresses there issues will follow in a minute.
Created attachment 985 [details] patch for Image.php for fixing size and aspect ratio of SVG images without width/height attributes.
It looks like this would break if one but not both of $width and $height is specified. These lines are doing arithmetic against the strings: + if ( !$width ) $width = $height ? ( $height * $f ) : 2048; + if ( !$height ) $height = $width / $f; while the input values are only later normalized to pixel sizes.
Created attachment 1026 [details] updated patch I hope I fixed all issues now.
Created attachment 1027 [details] fixed float behavior gave it another go...
SVG 1.1 spec says viewBox values are "separated by whitespace and/or a comma", but this seems to check whitespace only. wfScaleSVGLength should probably just always return a float. If you want to check for unset stuff, set the false ahead and check for the false to remain after *not* setting the value different. There is for instance a running of wfScaleSVGLength() on false values added in this patch, which should just leave the prior code intact. Better not to try looking for exact 0 values probably (especially if one's an int and one's a float so they won't match!) + $f = $w / $h; There's no guard against a float divide-by-zero; this may produce a runtime warning. (The check for === 0 will fail if given a float 0.0.) + $width= round( $width ); bad spacing on these lines
*** Bug 4609 has been marked as a duplicate of this bug. ***
Removing bogus dependency; this was for interpretation of the file contents by MediaWiki.
*** Bug 11163 has been marked as a duplicate of this bug. ***
Just noting that the example in bug 11163 has width="100%" height="100%" and requires the same sorts of viewBox hacks, presumably.
Added this w/ the new SVG size arch in r44651 / r44652. Should also handle percentages on the width element reasonably, I hope. :)