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
reasons
I think guys need this feature.Because many guys do not want to change local file name before upload.
This shouldn't happen by default, but should be possible through config, agreed.
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:
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.
@tech4him1 doesn't your slug sanitization work provide a solution for this?
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 https://github.com/netlify/netlify-cms/pull/1135.
Also @DomtronVox, uploading an image of the same name as an existing image currently triggers a prompt, it won't just overwrite.
It would be good if panel prompted the name before commit. As the config option.
@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?)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:
Editable filenames is mostly a UI problem. The more complex issue of creating and enforcing slugs is larger than the problem at hand (#445).
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.
I am not familiar with the codebase. Where should I look to allow renaming a file prior to upload in the UI?
Most helpful comment
This shouldn't happen by default, but should be possible through config, agreed.