SVG missing viewBox - cannot be resized with css
tobz-nz opened this issue · 1 comments
tobz-nz commented
Currently if you try to set the size of the svg via css the svg content is not resized to match but instead is clipped.
To fix the issue and resize the image as expected:
$svg = '<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" width="'.$this->width.'" height="'.$this->height.'" viewBox="0 0 '.$this->width.' '.$this->height.'">';
Also as an aside, this markup is way overkill. The only attribute required would be viewBox
(and width
/height
to set the size without css)
So:
$svg = '<svg width="'.$this->width.'" height="'.$this->height.'" viewBox="0 0 '.$this->width.' '.$this->height.'">';
is enough when rendering within an HTML page.
Happy to PR this (either option suggested) if you like.
uyab commented
I don't have deep knowledge about SVG, so PR are welcome :)