Problem/Motivation
When user adds a new media via the Media directories -entity browser, the media name is autofilled as the name of the file and there are users who dislike this feature.
Steps to reproduce
Add a new media in the Media directories -entity browser and see that the name is autofilled when the file is uploaded.
Proposed resolution
To add a way of disabling the autofill if wanted, the media type mapping could be used. As suggested in the core issue https://www.drupal.org/project/drupal/issues/3185321, the users who want the media name autofilled, could add a mapping in /admin/structure/media/manage/ in the "Name" part of the "Field mapping" section.
Remaining tasks
Code changes to add a check if mapping has been added for the media Name-field and act depending on that.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | media-directories-media-name-autofill-3377412-2.patch | 881 bytes | thatguy |
Comments
Comment #2
thatguy commentedAdded a check if the mapping has been added in the media type, copied from Lendude's solution in https://www.drupal.org/project/drupal/issues/3185321#comment-14349402
Comment #3
thatguy commentedComment #4
ytsurkThank you for your suggestion.
I think we can pre-release this core-feature in this module.
Comment #5
rang501 commentedThis seems to work as expected.
Steps:
1. Apply the patch
2. Add new media (I used image), file name was prefilled as I have the mapping set (default in Drupal install)
3. Change the name mapping value to Skip, and expose the name field (it is still pre-filled if the name field is not exposed on the form)
4. Upload a new image, field is empty.
Comment #6
rang501 commented