Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 300812

Users expect rendered media, not links, and configuring the entity reference display and view mode properly is challenging

$
0
0

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:

  1. Go to 'Manage display' and select 'Rendered Entity' formatter
  2. Configure 'Rendered Entity' formatter (this is where you should get told that you need a image style and view mode?)
  3. Save node view mode with new formatter for media field.
  4. Create new image style.
  5. Configure image style.
  6. Save image style.
  7. Create view mode for media.
  8. Save view mode for media.
  9. Enable new view mode for media bundle (this needs to happen for every bundle enabled on the field).
  10. Configure new view mode for media bundle.
  11. Enable new image style on the image field.
  12. Save the media view mode.
  13. Go back to node view mode.
  14. Configure the media field to use the new view mode.
  15. 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


Viewing all articles
Browse latest Browse all 300812

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>