Support for core's media view mode selection

Created on 20 May 2025, 1 day ago

Problem/Motivation

For media you can allow the user to change the view mode in the editor.
But resizing an image overrides this setting to one of the view modes assigned by width of the image.
So if you want to apply a specific image style through a view mode, it does not get applied.

Steps to reproduce

  • Create image style with different ratio than original image (for example with scale and crop).
  • Create a view mode for your image media, set the image field to use this style
  • Edit a text format. Under "Media", tick box for "Allow the user to override the default view mode". Under "Embed media" select view modes to be selectable.
  • Create a new node with a media image in your editor. Apply a view mode, then resize the image to make it smaller.
  • The saved node does not show the image with the style from the view mode selected.

Proposed resolution

Check the data-view-mode attribute before setting it in the filter.
Maybe recommend the use of the combined_image_style module and if it's installed, combine the styles from the two view modes.
This will likely require some altering when the media is rendered.

Feature request
Status

Active

Version

1.0

Component

Code

Created by

🇩🇪Germany m-p-j

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024