Not able to render html in figcaption for media block

Created on 31 July 2023, 11 months ago
Updated 3 June 2024, 23 days ago

Hi, I noticed that the figcaption behaves differently on the GB core image block vs. the media block, specifically that while you can add html comtent to the caption in the media block, this will not render.

Here is how the image block looks (adding an image via the media library):

And here is how it looks when using the media block (again adding an image via the media library)

And this is the rendered result:

The article code editors looks like this:

<!-- wp:image {"id":11,"sizeSlug":"large","linkDestination":"none","mediaAttrs":{"data-entity-type":"file","data-entity-uuid":"00627a39-c916-4579-8706-284c06d8ad79","data-image-style":"original"}} -->

<figure class="wp-block-image size-large"><img src="/sites/default/files/styles/large/public/2023-07/CleanShot%202023-07-31%20at%2012.44.26%402x.png?itok=ooE9420p" alt="test" class="wp-image-11" data-entity-type="file" data-entity-uuid="00627a39-c916-4579-8706-284c06d8ad79" data-image-style="original"/>

<figcaption>I can have <strong>html</strong> here </figcaption></figure>
<!-- /wp:image -->

<!-- wp:drupalmedia/drupal-media-entity {"mediaEntityIds":["2"],"caption":"I am not able to \u003cem\u003erender\u003c/em\u003e the \u003cstrong\u003ehtml\u003c/strong\u003e here"} /-->

and source code:

There is a UI to add html to the caption, and when editing the article again the caption data in the media block is decoded properly. It's only when you view the article that it is not html anymore.

🐛 Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

🇳🇴Norway vegardjo

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

Merge Requests

Comments & Activities

Production build 0.69.0 2024