- Issue created by @nyanmar
- Status changed to Postponed: needs info
9 months ago 1:37pm 12 February 2024 - 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
According to the
InsertDrupalMediaCommand
docs this should be possible:/** * The insert media command. * * The command is registered by the `DrupalMediaEditing` plugin as * `insertDrupalMedia`. * * In order to insert media at the current selection position, execute the * command and pass the attributes desired in the drupal-media element: * * @example * editor.execute('insertDrupalMedia', { * 'alt': 'Alt text', * 'data-align': 'left', * 'data-caption': 'Caption text', * 'data-entity-type': 'media', * 'data-entity-uuid': 'media-entity-uuid', * 'data-view-mode': 'default', * }); * * @private */ export default class InsertDrupalMediaCommand extends Command {
I wonder if this is a bug in
DrupalMediaUI
, where it does:this.listenTo(buttonView, 'execute', () => { openDialog( libraryURL, ({ attributes }) => { editor.execute('insertDrupalMedia', attributes); }, dialogSettings, ); });
👆 as you can see, it passes on all attributes it receives!
- Status changed to Fixed
9 months ago 3:43pm 29 February 2024 - 🇦🇺Australia mstrelan
I was able to get the
data-caption
attribute inserted in the source by adding it in thethis.attrs
andthis.converterAttributes
in the constructor of theDrupalMediaEditing
plugin thanks to @rikki_iki but it isn't editable, and pressing the "Toggle caption on" button adds an extra caption, overriding the original.Attaching a patch to demonstrate, and a screencast below.
- Status changed to Active
8 months ago 1:13am 14 March 2024 - 🇦🇺Australia mstrelan
I've used CKEditor Inspector to compare the model of a working media with caption with what I'm getting with the patch.
Working:
<drupalMedia drupalMediaEntityType="media" drupalMediaEntityUuid="..." drupalMediaIsImage="true" drupalMediaType="image"> <caption>Test caption</caption> </drupalMedia>
Not working:
<drupalMedia drupalMediaCaption="Test caption" drupalMediaEntityType="media" drupalMediaEntityUuid="..." drupalMediaIsImage="true" drupalMediaType="image"> </drupalMedia>
I believe the issue is that the upcast converter is doing a simple
attributeToAttribute
conversion whereas it needs special handling for the caption. I guess theDrupalMediaCaptionEditing
should take care of that but it just needs to be triggered some how. - Status changed to Needs review
8 months ago 3:32am 14 March 2024 - 🇵🇰Pakistan jibran Sydney, Australia
Updated the title and re-categories the issue. Let's update the IS with steps to reproduce.
- Status changed to Needs work
8 months ago 3:44am 14 March 2024 The Needs Review Queue Bot → tested this issue.
While you are making the above changes, we recommend that you convert this patch to a merge request → . Merge requests are preferred over patches. Be sure to hide the old patch files as well. (Converting an issue to a merge request without other contributions to the issue will not receive credit.)