Template in src/components/figure/figure.twig in Radix should not check whether "caption" exists

Created on 5 March 2021, about 4 years ago
Updated 20 October 2023, over 1 year ago

Drupal version 8.8+ offers a new embed media library functionality in the CKeditor. Content editor can embed a drupal media using the new media library. When embedding an image that has caption, it would say "Enter caption here" underneath the media image. Unfortunately it doesn't work very well with Radix. The placeholder "Enter caption here" is nowhere to be seen, so you can't enter the caption.

After debugging, I found that it was due to the template file: "templates/field/filter-caption.html.twig"; which loads "src/components/figure/figure.twig", having caption conditional check before rendering it.

Besides that, also the class "caption" must be present in the figure tag.

Not working:

{% set classes = [
  'figure',
]|merge(utility_classes ? utility_classes : []) %}

<figure{{ attributes.addClass(classes) }}>
  {{ image }}

  {% if caption %}
    <figcaption class="figure-caption">{{ caption }}</figcaption>
  {% endif %}
</figure>

Working:

{% set classes = [
  'figure',
  'caption',
]|merge(utility_classes ? utility_classes : []) %}

<figure{{ attributes.addClass(classes) }}>
  {{ image }}

  <figcaption class="figure-caption">{{ caption }}</figcaption>
</figure>

All other themes (e.g. bartik, olivero) don't have caption conditional check in their templates.

🐛 Bug report
Status

Fixed

Version

4.10

Component

Code

Created by

🇮🇩Indonesia rarioj

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇳🇿New Zealand jweowu

    The template committed here seems bad to me.

    Bootstrap contains the following:

    .media {
      display: flex;
      align-items: flex-start;
    }
    

    And the new template sets the class "media".

    As this is a Bootstrap-based theme, that's quite a change to suddenly impose.

    Was this specific interaction intentional?

    If not, please change the class in the template to something different...

Production build 0.71.5 2024