Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for querying SVGs as images #3277

Closed
kripod opened this issue Dec 19, 2017 · 5 comments
Closed

Add support for querying SVGs as images #3277

kripod opened this issue Dec 19, 2017 · 5 comments

Comments

@kripod
Copy link
Contributor

kripod commented Dec 19, 2017

I 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.

@KyleAMathews
Copy link
Contributor

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 to public/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?

@kripod
Copy link
Contributor Author

kripod commented Dec 20, 2017

This sounds absolutely great! Unfortunately, I'm pretty busy nowadays, so I cannot do a PR.

@kripod
Copy link
Contributor Author

kripod commented Jan 17, 2018

@KyleAMathews Also, I think this proposal might be interesting for Gatsby v2: facebook/create-react-app#3722

@CanRau
Copy link
Contributor

CanRau commented Mar 4, 2018

publicURL has been added and works for me #3669
is this what you mean @kripod? or does it help?

@kripod
Copy link
Contributor Author

kripod commented Mar 4, 2018

@CanRau yeah, it’s fine now.

@kripod kripod closed this as completed Mar 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants