SVGs with missing width, height and viewbox cause errors
See original GitHub issueIf you try to add an SVG file without a width
, height
and viewBox
element, the script returns an error exactly where it should report the missing file.
The file
variable is used in a previous Promise function, but is no longer available (since the code has gone to a new then
node).
I might write a PR for this, but don’t have the time right now.
A hotfix is to replace this line with a return;
statement, but it’s not helping anyone solve the issue.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:10 (6 by maintainers)
Top Results From Across the Web
css - SVG height incorrectly calculated in Webkit browsers
The issue is that although the SVG displays at the correct size (its' height being determined in ratio to the width, and as...
Read more >SVG size issue after update - WordPress.org
Safe SVG has logic to get the height and width of an SVG from the height and width attributes. If those don't exist,...
Read more >Here's How I Solved a Weird Bug Using Tried and True ...
The SVGs have been exported from a design tool and have no syntax errors. The SVGs have some CSS applied to them from...
Read more >SVG with no explicit width and height is not rendered correctly ...
I would suggest a fallback to the viewbox attribute for width and height. 2 Likes. RaananW March 22, 2021, 7 ...
Read more >Creating a responsive SVG with no aspect ratio | J Scott Smith
Just make sure to set the background-size to 100% if you want it to always fill to the edges. Additionally, you could limit...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Sorry @cascornelissen for the delay, the project I was using it in had taken a sharp turn when I spent too much time figuring this out.
I re-tried it in a different project (gumbo-millennium/website) and added this invalid SVG:
The result looks promising:
edit
However, it also seems that WebPack isn’t too fond of not using Promise.catch, since it also spits out this beauty:
@alpezed, I’m not 100% I understand but the
svg-spritemap-webpack-plugin
needs to know the height and width of each SVG that you want to end up in the spritemap. Without knowing the width/height of an SVG file it can’t calculate where the file should be placed in the generated spritemap.