-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
uploaded filenames not being slugified #1196
Comments
@thauvette Are you using a private GitHub repo? If so, does the image preview show up if you reload the CMS? If both are true, this will be fixed in #994. |
@tech4him1 yes to both. |
@thauvette Thanks. I'm thinking the preview breaking happens to images without a space as well, can you confirm? |
@tech4him1 yes it does. |
On the Gatsby issue, what does the image name show up as in the GitHub? Does it show with the |
In Gatsby it's spaces as well. If it's a preview image or thumbnail, anything inside the frontmatter I'm using |
I guess I don't understand why it needs to be URL-encoded in the frontmatter, instead of on-the-fly like would normally be done. Have you tried it without |
#1135 will convert spaces to dashes in media by default. I think that's your preference here, anyway? |
@tech4him1 I'm using If I understand #1135 I need to use
with no success. |
I definitely won't claim to be an expert here, but I've never heard of it working like that. Gatsby and/or your browser should do that transparently.
Again, I'm no Gatsby expert, but that sounds completely correct to me (without
#1135 hasn't been merged/released yet, but as soon as it is, it should sanitize/slugify automatically without any extra setting (it was kind-of a "side effect" of the PR 😄). |
Thanks @tech4him1, I'll investigate it as a Gatsby issue and report back here if I figure it out. |
@tech4him1 I recreated this issue using the Gatsby Netlify CMS starter. If you upload a file (picture) with a space in the filename the same errors occur. No thumbnail and 404 console error... The image appears in the preview... But not the post... It may just be the way it is until #1135 is merged? |
Thanks for the repro! Looks like the difference between how we can render images with spaces in the name and Gatsby fails to is due to the difference in Markdown specs. 🙄 According to the original Markdown syntax document:
This doesn't specify whether image URLs can include spaces or not. CommonMark, however, excludes spaces from URLs:
The space must be converted to Like you said, I think the best way for us to fix this is just strip spaces out, which we will do as part of #1135. |
Fixed in #1135. |
- Do you want to request a feature or report a bug?
Bug
- What is the current behavior?
If I upload an image with a space in the filename, let's say "my picture.jpg" the following happens.
I get a 404 error in the console saying can't find " https://raw.githubusercontent.com/myusername/reponame/branch/path/to/my/uploads/my%20picture.jpg".
I can still "Choose Selected" on the un-previewable thumbnail and the image shows in the CMS preview with the file name "my picture.jpg". If I publish the post the image is saved as "/path/to/my/uploads/my picture.jpg" and not "/path/to/my/uploads/my%20picture.jpg". This, of course, doesn't work well with Gatsby.
- If the current behavior is a bug, please provide the steps to reproduce.
- What is the expected behavior?
I think the files should save as "my%20picture.jpg" not "my picture.jpg"
- Please mention your CMS, node.js, and operating system version.
CMS - netlify-cms@1.3.5
node v8.9.4
- Please link or paste your
config.yml
below if applicable.The text was updated successfully, but these errors were encountered: