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

Comments

phenaproxima created an issue. See original summary.

jeroent’s picture

dagomar’s picture

I'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.

berdir’s picture

Status: Active » Needs review

Yeah, 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.

Status: Needs review » Needs work

The last submitted patch, 3: add-name-field-in-view-display-3089416-3.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.