Problem/Motivation
By default, when you add a media field to a content type, it will default to rendering a link to the entity, rather than rendering (e.g.) your image on your content the way a user expects. Furthermore, the process of properly configuring the view mode and image style for the desired display is very complicated. (This is a problem for entity reference fields generally, but worse for media.)
An example of this is when you reference media entities and want to display a image field in a lot of different image styles. Needing a view mode for each image style to display is not very user friendly.
The problem of "I need to display part of a referenced entity as though it were part of the referencing entity" pops up many times in the course of normal Drupal development.
This video illustrates the steps required: https://www.drupal.org/files/issues/rendered-entity-formatter-steps.mp4
Steps required:
- Go to 'Manage display' and select 'Rendered Entity' formatter
- Configure 'Rendered Entity' formatter (this is where you should get told that you need a image style and view mode?)
- Save node view mode with new formatter for media field.
- Create new image style.
- Configure image style.
- Save image style.
- Create view mode for media.
- Save view mode for media.
- Enable new view mode for media bundle (this needs to happen for every bundle enabled on the field).
- Configure new view mode for media bundle.
- Enable new image style on the image field.
- Save the media view mode.
- Go back to node view mode.
- Configure the media field to use the new view mode.
- Save the node view mode.
This is clearly a lot more complicated than configuring the display of core image fields, and more than site builders will figure out on their own!
Proposed resolution
The previous approach created a generic, reusable formatter to display a field from the referenced entity, but this solution raised a number of concerns and limitations (see #103, #123, #136, etc.). (The formatter may be available in contrib instead; see #2894947: Add a formatter to display a rendered field from a referenced entity.)
The new approach focuses on providing better defaults in core, and allowing an image style to be selected through the field UI.
Remaining tasks
- Fix the bugs indicated in #183
- Extend test coverage
- Review
- Collect sign-off & RTBC