[gatsby-plugin-sharp] Traced SVG scaling issue in Internet Explorer #22169
Labels
status: confirmed
Issue with steps to reproduce the bug that’s been verified by at least one reviewer.
type: bug
An issue or pull request relating to a bug in Gatsby
Description
The Traced SVG placeholders for my images are not scaling in alignment to the actual images in Internet Explorer.
Steps to reproduce
Expected result
Traced SVG placeholders should be aligned with the actual images in Internet Explorer, like it is in other browsers. It should look like this:
Actual result
In most cases the Traced SVG placeholder is not aligned with the actual image in Internet Explorer (tested with IE 11). It looks like this:
Environment
Some investigation
viewBox
property (see: https://stackoverflow.com/questions/27970520/svg-with-width-height-doesnt-scale-on-ie9-10-11).gatsby-plugin-sharp
uses the SVGO library to optimize and minimize the generated Traced SVGs, which by default removes theviewBox
property.viewBox
property by default, where I also added a comment mentioning the IE problem: What is the benefit of stripping viewBox? svg/svgo#1128Possible fix
viewBox
property fixes most cases in IE11 while it seems to not change any behavior in other browsers (tested in Chrome v80).gatsby/packages/gatsby-plugin-sharp/src/trace-svg.js
Line 71 in dc4e21e
removeViewBox
plugin like so:gatsby-image-wrapper
is 1:1. For other cases we also need to set thepreserveAspectRatio='none'
to fix it. I did not check if this would have side effects. But it could be done using the SVGO addAttributesToSVGElement plugin.Next steps
preserveApectRatio
property?The text was updated successfully, but these errors were encountered: