Problem/Motivation
In core/modules/media_library/templates/media--media-library.html.twig, we have this:
<div{{ preview_attributes }}>
{{ content|without('name') }}
</div>
{% if not status %}
<div class="media-library-item__status">{{ "unpublished" | t }}</div>
{% endif %}
<div{{ metadata_attributes }}>
<div class="media-library-item__name">
{{ name }}
</div>
</div>
That kind of sucks. It would be nice if name were treated as a normal field and could be configured in the entity view display.
Proposed resolution
Make the Name field, and potentially other base fields, configurable in the entity view displays for media items.
Remaining tasks
Figure out the scope of what we should do, then do it and bother committers until they land it.
User interface changes
TBD, likely none.
API changes
TBD, likely none.
Data model changes
TBD, likely none.
Release notes snippet
TBD
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | add-name-field-in-view-display-3089416-3.patch | 14.48 KB | dagomar |
Comments
Comment #2
jeroentComment #3
dagomar commentedI'm attaching a patch for a slightly different approach. To keep the change as much in line with how it currently works - namely the distinction between preview and metadata - the template still uses/hardcodes the name field. However, the display of said field is now based on whether the field is actually configured in the Media Library view mode of the entity. This means you can optionally remove the name field. Other fields are displayed in the preview section of the template.
The patch covers the twig change, a small change to the css, update and a test of the latter.
I've discussed this solution with both @seanB and @chr.fritsch at Drupalcon Amsterdam.
Comment #4
berdirYeah, see the related meta issue and massive discusions there and in related issues about BC for the similar node fields title/author/created and so on.