Support SVG images defined in metadata #68
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
While looking at quarkusio/quarkus#30459, @maxandersen and @gsmet asked about SVG support. I had to test SVG support, since I’m relying on the framework for image processing. By default, SVG doesn’t work, so I’ve added some extra implementation to support it.
This only covers the case where the image is set in the extension yaml. If we’re getting the image from GitHub, they have their own rules, which exclude SVG.
I followed the hints in https://stackoverflow.com/questions/53628498/gatsby-image-svg-not-found. Using a raw
<img
tag feels a bit odd, buthttps://stackoverflow.com/questions/71665446/how-to-render-svg-files-with-gatsby-image confirms it’s a sensible thing to do. (The react plugin is solving a different problem to what we have.)
To increase the chances of the svg being rendered at the right size, I set a size explicitly on the image itself; I'm not going to be able to tamper with the viewbox of the SVG itself, but
<img
size should work on most browsers except maybe IE. In my testing, it displayed fine even without the size, I assume because we're usually shrinking it from larger originals.