-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
[gatsby-plugin-sharp] Url Encoding Image File Names #10650
Conversation
Fixes broken srcset images
Hi, thanks for the PR! 👍 Do you feel comfortable adding a test to make sure that spaces/weird characters are handled correctly? Please let us know if you need help. Thanks! |
Hi @LekoArts , thanks for the help! I've never written a test before 😛but it was a cool & useful thing to learn! Lemme know if it looks good to go! |
hmm not sure whats going on re: these checks. |
We merged PR earlier that had linting errors and those probably came from that - after syncing your branch it was fixed. For remote files we probably would want to apply encoding in https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-source-filesystem/src/create-remote-file-node.js#L227-L231, but your change also makes sense - there can be local image files with spaces in name so this is definitely needed here too. ---edit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @huntercaron! 🙏
Holy buckets, @huntercaron — we just merged your PR to Gatsby! 💪💜 Gatsby is built by awesome people like you. Let us say “thanks” in two ways:
If there’s anything we can do to help, please don’t hesitate to reach out to us: tweet at @gatsbyjs and we’ll come a-runnin’. Thanks again! |
Thanks @pieh! |
Uses `encodeURI()` to fix an issue with image files that contain spaces in the name breaking srcset. This encodes the file names with the appropriate `%20` and such.
Uses
encodeURI()
to fix an issue with image files that contain spaces in the name breaking srcset.Client was adding images to the CMS backend with spaces in the name, which were breaking the srcset image links. This encodes the file names with the appropriate
%20
and such.(if there is a better place to put it please suggest!)
Before
After
Thanks!