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

Option to maintain original image name when using createRemoteFileNode #40

Closed
simplesessions opened this issue Jun 6, 2018 · 4 comments

Comments

@simplesessions
Copy link
Collaborator

Currently, integration with gatsby-image/gatsby-plugin-sharp creates images that are fully hashed. However, it would be great to append the original filename to the end of the filename before the ext.

This mainly benefits SEO, but it also helps to quickly identify them when scanning through code and looking at resources when testing loading.

This matches the way Prismic handles their images, e.g.

  • filename: i-like-to-eat-babies.jpg
  • served as: 299426612ab3f0385acd5cf114ab263b85778379_i-like-to-eat-babies.jpg
@angeloashmore
Copy link
Member

I have to look more into this. I'm not sure where in gatsby-plugin-sharp or gatsby-transformer-sharp transforms the filename. It might even be in gatsby-source-filesystem since gatsby-source-prismic uses createRemoteFileNode from that package.

That's a lot of gatsby-s.

@simplesessions
Copy link
Collaborator Author

simplesessions commented Jun 9, 2018

Looks like we're out of luck for the short-term:

https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-source-filesystem/src/create-remote-file-node.js#L190-L191

Where createHash() is:
https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-source-filesystem/src/create-remote-file-node.js#L56-L60

An ideal situation would be for createRemoteFileNode to at least provide a function to allow you to perform your own hashing function with access to the the URL as an arg so you can regex and pluck the original filename in cases like Prismic where a hash is already prepended, then tell createRemoreFileNode to prefix the result to the hash: ${hash}_${filename}.${ext}.

@angeloashmore
Copy link
Member

Looks like there may be some hope here: gatsbyjs/gatsby#3132

@angeloashmore
Copy link
Member

Closing out this ancient issue. This is present in gatsby-source-filesystem now.

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

2 participants