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.

Comments

thatguy created an issue. See original summary.

thatguy’s picture

Added 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

thatguy’s picture

Status: Active » Needs review
ytsurk’s picture

Thank you for your suggestion.

I think we can pre-release this core-feature in this module.

rang501’s picture

Status: Needs review » Reviewed & tested by the community

This 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.

rang501’s picture

Status: Reviewed & tested by the community » Closed (won't fix)

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.