Problem/Motivation

Discovered in #3245720: [drupalMedia] Support choosing a view mode for <drupal-media> and split from #3276670: Some configurations of allowed view modes cause CKE to fail to initialize.

When the user sets a default view mode as a view mode that is not allowed for a certain bundle (media type), it applies that view mode to the element anyway. In my screenshot below, I configured my document media type so that "tiny" view mode is not allowed. However as you can see in the source code, it has "tiny" on the element. (Below screenshot is CKEditor 5 but same thing happens for CKEditor 4)

Looking at \Drupal\media\Plugin\Filter\MediaEmbed::process(), I don't think it's taking into account that the view mode may not exist for the bundle (MediaType). So that'd be another bug in the media module, not in the CKEditor 5 module.

— from #3276670-5: Some configurations of allowed view modes cause CKE to fail to initialize

Steps to reproduce

1. Go to /admin/structure/media/manage/document/display (or whatever media type)
2. In Custom display settings, do not check whatever view mode you want to test with.
3. Go to your editor configuration and under embed media, set the Default view mode to that view mode from #2.
4. Go to your editor and insert a document and check the source code of that element and you should see the view mode that should not be allowed.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Comments

hooroomoo created an issue. See original summary.

hooroomoo’s picture

Title: A default view mode that isn't allowed for a bundle gets applied anyway » A default view mode that isn't allowed for a media type gets applied anyway
Issue summary: View changes
wim leers’s picture

Title: A default view mode that isn't allowed for a media type gets applied anyway » media_embed filter: a default view mode that isn't allowed for a media type gets applied anyway

👍 Great write-up! 👏

Version: 10.0.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. 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.