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

How to auto rename the file name of uploaded file or image? #857

Open
alexliyu7352 opened this issue Dec 1, 2017 · 15 comments
Open

How to auto rename the file name of uploaded file or image? #857

alexliyu7352 opened this issue Dec 1, 2017 · 15 comments
Labels
area: media-library good first issue kind: discussion status: accepted type: feature code contributing to the implementation of a feature and/or user facing functionality

Comments

@alexliyu7352
Copy link

How to auto rename the file name of uploaded file or image?
I mean when i upload an image or file, how to auto rename it?like slug, or use timestamp to file name

@alexliyu7352
Copy link
Author

reasons

  1. overwrites
  2. add the date-time or other prefix to file name is good for manager. like slug
  3. good for privacy protection, Because many files`s name is privacy

@alexliyu7352
Copy link
Author

I think guys need this feature.Because many guys do not want to change local file name before upload.

@erquhart
Copy link
Contributor

erquhart commented Dec 9, 2017

This shouldn't happen by default, but should be possible through config, agreed.

@DomtronVox
Copy link

I would like to add a 4th to the list. Recently I had an issue with a non-technical person uploading an image that had special characters (in my case the # sign) causing the static site to have an error during its' build. So:

  1. Allows sanitizing uploaded file's name for technical reasons.

I think the fix for all these may need to be separate features though. 2-4 seem to work well with an automatic approach, but overwrites (no. 1) should probably have an option similar to delete in the media manager. Could be called reupload, but that might be too close to "upload" and be confusing to some.

You shouldn't be able to replace an image file just by uploading another of the same name as this could cause loss of data problems. So it should either follow a delete file -> upload new file pattern or have a special upload mode specifically for replacing.

@erquhart
Copy link
Contributor

@tech4him1 doesn't your slug sanitization work provide a solution for this?

@tech4him1
Copy link
Contributor

tech4him1 commented Feb 27, 2018

4. Allows sanitizing uploaded file's name for technical reasons.

@tech4him1 doesn't your slug sanitization work provide a solution for this?

Sanitizing media filenames is part of #1135.

@erquhart
Copy link
Contributor

Also @DomtronVox, uploading an image of the same name as an existing image currently triggers a prompt, it won't just overwrite.

@vintprox
Copy link

It would be good if panel prompted the name before commit. As the config option.

@pungggi
Copy link

pungggi commented Jun 7, 2018

@erquhart Can we agree on the options ?

Suggestions:

OptionField Value Behaviour
prompt if option filename is not set, then same behaviou as of now
prompt true prompts for a filename
filename {{collection}}__{{year}}-{{month}}_{{filename}} composes filename. if prompt is set to true this is used as a suggestion

Same tags available as https://www.netlifycms.org/docs/configuration-options/#slug
In addition:

  • {{filename}}: original name of the file
  • {{collection}}: name (or label?) of the collection
  • {{myField}}: value of a custom field in the collection (< is this possible?)
  • {{counter}}: a counter within a list or collection (< is this possible?)

@erquhart
Copy link
Contributor

Templated default filenames makes sense, as well as prefixing and only allowing the user to add/edit a portion of the resulting filename (maybe). That's separate from the core issue of making the filename editable though. We should split this issue into two concerns:

  1. Make filenames editable.
  2. Provide "slug" features for media filenames.

Editable filenames is mostly a UI problem. The more complex issue of creating and enforcing slugs is larger than the problem at hand (#445).

@stale
Copy link

stale bot commented Oct 29, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@belmarca
Copy link

I am not familiar with the codebase. Where should I look to allow renaming a file prior to upload in the UI?

@erezrokah erezrokah added good first issue area: media-library type: feature code contributing to the implementation of a feature and/or user facing functionality and removed status: stale kind: feature labels Sep 28, 2020
@Soneji
Copy link
Contributor

Soneji commented May 5, 2021

Hi

Is this still something people want? I certainly would love to be able to rename my files/images before uploading them. If a maintainer could point me in the direction of the code for handling file uploads I would be happy to send a PR

Thanks

@erezrokah
Copy link
Contributor

Hi @Soneji, maybe we can do this as a part of #4965?

The UI code for the media library is here https://github.com/netlify/netlify-cms/tree/master/packages/netlify-cms-core/src/components/MediaLibrary

@treshenry
Copy link

👍

For another angle: I have clients that use an iPad to update content. It's awesome that they can select a photo from the iPhoto library on the device, however, iPhoto appears to export the image with a GUID file name. Being able to customize the file name at the time the file is uploaded would solve this issue. I mean, this is clearly iPhoto's fault... but since there's already a ticket open... 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: media-library good first issue kind: discussion status: accepted type: feature code contributing to the implementation of a feature and/or user facing functionality
Projects
None yet
Development

No branches or pull requests

10 participants