Allow attribute mapping to be modified in MediaWysiwygFilter

Created on 26 April 2025, 1 day ago

Problem/Motivation

It would be useful to be able to customize media mappings to allow other modules to modify the structures.

A good use case would be ckeditor_media_resize that can resize an image via ckeditor.

[[{"fid": "1146","view_mode": "default","fields": {"format": "default","field_file_image_alt_text[und][0][value]": false,"field_file_image_title_text[und][0][value]": false,},"type": "media","link_text": null,"field_deltas": {"1": {"format": "default","field_file_image_alt_text[und][0][value]": false,"field_file_image_title_text[und][0][value]": false,}},"attributes": {"height": 323,"width": 400,"style": "height: 283px; width: 350px; margin: 5px 8px; float: right;","class": "media-element file-default","data-delta": "1"}}]]

With ckeditor_media_resize this might be something like this:
<drupal-media data-entity-type="media" data-entity-uuid="00517131-5632-4716-a835-3e30f3200517" style="width:400px;" class="media-embed-resized">

Steps to reproduce

Proposed resolution

At the end of MediaWysiwygFilter::transform() initiate a hook that allows the attributes to be modified, e.g.:

hook_media_wysiwyg_filter_alter($embed_metadata, $source_attributes);
?>

Remaining tasks

Build the hook.

API changes

A new hook is available called hook_media_wysiwyg_filter_alter().

✨ Feature request
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States DamienMcKenna NH, USA

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024