Problem/Motivation

When adding a media item with a file based media source (file/image/video etc), the media name is automatically set to the file name. When updating that media item with a new file, the name of the media item is not automatically updated to the new file name.

Proposed resolution

Expose the filename as metadata for file based media sources, to allow media types to be configured to automatically update the media name when a new file is uploaded for a media item.

Remaining tasks

User interface changes

New 'name' metadata to be configured in media types.

API changes

None

Data model changes

None

Comments

axel.rutz created an issue. See original summary.

geek-merlin’s picture

Patch flying in that might fix this.

berdir’s picture

I don't think that is correct, you can't search or sort for that name then.

Maybe it could be updated but we would have to know that it was the default.

geek-merlin’s picture

Good point. So we might need a setting for that, otherwise we can't discern a entered from a autogenerated name.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

seanb’s picture

Status: Active » Needs review
StatusFileSize
new3.66 KB

To fix this, we should be able to map the filename to a field. This would automatically update the media title and also allow users to hide the name field on the media form if the want to for #2882473: Hide the media name basefield from the entity form by default.

Having some issues running the new javascript tests locally, so hope this works.

phenaproxima’s picture

Issue tags: +Media Initiative
marcoscano’s picture

Status: Needs review » Reviewed & tested by the community

+1

RTBCing in the assumption it will become green.

Thanks!

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 6: 2933012-6.patch, failed testing. View results

seanb’s picture

Status: Needs work » Needs review
StatusFileSize
new3.67 KB
new939 bytes

Still having issues with my tests, hope this helps.

Status: Needs review » Needs work

The last submitted patch, 10: 2933012-10.patch, failed testing. View results

seanb’s picture

Status: Needs work » Needs review
StatusFileSize
new3.65 KB
new937 bytes

Please let this work...

Status: Needs review » Needs work

The last submitted patch, 12: 2933012-12.patch, failed testing. View results

seanb’s picture

Status: Needs work » Needs review
StatusFileSize
new3.83 KB
new856 bytes

Getting close...

marcoscano’s picture

Status: Needs review » Reviewed & tested by the community

Once now it's green, back to RTBC! :)

alexpott’s picture

Status: Reviewed & tested by the community » Needs review
Issue tags: +Needs upgrade path

I think we have to do an upgrade path because media has been stable since 8.5.0 no?

marcoscano’s picture

Mm, not sure I understand the need for the upgrade path. This patch exposes for the File, Image, Audio and Video source plugins the name of the file as a metadata attribute. This means that media types using these sources will now be able to use this new metadata attribute in the field mapping, if they want to. Once before the patch they didn't have this possibility, I'm not sure what the upgrade path should do?

Thanks!

alexpott’s picture

So then does this really solve the problem? As far as I can see, at the moment we use the filename as the default name and then the file entity can change its name and the media entity won't be updated. With this patch the site builder can enable the name mapping and then the name will be automatically updated. But how is a site builder going to know to do this. Shouldn't this be the default behaviour - and should this even really be configurable?

alexpott’s picture

And what happens if you enable the mapping when entities already exist?

berdir’s picture

> So then does this really solve the problem?

It doesn't need to, we have more than one issue. We have #2882473: Hide the media name basefield from the entity form by default for example, which will be about whether or not we want to have those fields hidden by default in our default media types in standard/umami. But even then, I don't think we should have an upgrade path. We don't have upgrade path for configuration changes in standard IMHO, we could notify sites about the possibility but should leave it to them if they want to do that. And certainly not enforce on all media types.

seanb’s picture

Title: Change in file name not shown » Expose the filename as metadata for file based media sources
Category: Bug report » Feature request
Issue summary: View changes

Maybe this is more a feature request than a bug report. Since the name/title field is a special thing for entities, the way to solve this would be to automatically update the media name. I've updated the IS to better describe the problem and solution.

Since existing sites could depend on the media name NOT being automatically updated, I don't think this is something we should enable for existing sites. Existing sites could make use of this feature by adding the name mapping in the media type. We have #2882473: Hide the media name basefield from the entity form by default to discuss if we want to enable this for new sites by default.

*edit: Cross-posted with the last comments. Didn't mean to repeat points already mentioned.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

marcoscano’s picture

Status: Needs review » Reviewed & tested by the community

+1 for the reasoning above.
I've re-queued #14 against 8.7.x, and RTBCing under the assumption it will become green as well :)

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 14: 2933012-14.patch, failed testing. View results

marcoscano’s picture

Status: Needs work » Reviewed & tested by the community

Not sure about the failures in #14, seems like re-triggering them made it green... random failure?

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Okay I see - so this is an addition. This seems useful so let's put it in 8.6.x too.

Committed and pushed a061dd7edd to 8.7.x and 147357e302 to 8.6.x. Thanks!

  • alexpott committed a061dd7 on 8.7.x
    Issue #2933012 by seanB, axel.rutz, marcoscano, alexpott, Berdir: Expose...

  • alexpott committed 147357e on 8.6.x
    Issue #2933012 by seanB, axel.rutz, marcoscano, alexpott, Berdir: Expose...
geek-merlin’s picture

❤ Great it's already in!

alexpott’s picture

I backported this to 8.6.x as improved media handling is important for Drupal 8 and the change, now I grok it better, feels very low risk.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.