Add support for querying SVGs as images
See original GitHub issueI think it would be great if public URLs for SVGs could be generated through ImageSharp. Currently, if I want to use vector and raster graphics interchangeably, I need to use some extra code similar to below:
let thumbnailSrc;
if (video.frontmatter.thumbnail != null) {
thumbnailSrc =
video.frontmatter.thumbnail.childImageSharp != null
? video.frontmatter.thumbnail.childImageSharp.sizes.src
: `/${video.frontmatter.thumbnail.relativePath}`;
}
Also, I have to put all the related images to the /static
folder and make them discoverable by gatsby-source-filesystem. Querying SVGs just like raster images would simplify this workflow by a lot.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Using SVG with Media Queries - SitePoint
By using SVGs with media queries, we can change their appearance based on user interaction or viewport size, and use them in multiple ......
Read more >SVG (basic support) | Can I use... Support tables for ... - CanIUse
"Can I use" provides up-to-date browser support tables for support of front-end ... Method of displaying basic Vector Graphics features using the embed...
Read more >Media Queries in SVG images - Cloud Four
The really cool thing about the way media queries work inside SVG is that they react to the viewport of the image itself,...
Read more >Accessible SVGs | CSS-Tricks
Screen reader traversable – Make sure the SVG is traversable in all browsers by adding role="group" to the <svg> . According to the...
Read more >How to Use SVG Images in CSS and HTML – A Tutorial for ...
Assuming you downloaded the SVG image from unDraw and renamed it to happy.svg, you can go ahead and add the code snippet above...
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
I couldn’t find the issue where this has been discussed before but what I suggest is that we add to
File
nodes (from gatsby-source-filesystem) the ability to “query” the file which will cause them to be copied topublic/static
with a content addressed path.This would mean adding a new field e.g.
publicLink
(probably not the best name).How’s this sound? Would you like to do a PR?
@CanRau yeah, it’s fine now.