Embedded media does not show due to raw description format

Created on 27 August 2024, 3 months ago

Problem/Motivation

When using the Media module to embed media, the selected files do not appear on the timeline. This is because the template file uses the raw filter, which doesn't process the image correctly.

Steps to reproduce

1. Install Media module.
2. Add button to text editor and configure.
3. Within the timeline block, add an image using the Media button and submit changes.
4. The code for the image appears in source, but the image doesn't appear.

πŸ› Bug report
Status

Active

Version

1.1

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States bwoods

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

Comments & Activities

  • Issue created by @bwoods
  • πŸ‡ΊπŸ‡ΈUnited States bwoods

    I was able to get this to work by using the processed_text formatter. Here is a code sample that I used in timeline-block.html.twig:

        {% for key,timeline in timeline_data %}
        
          {% set tl_description = {
        	'#type':   'processed_text',
        	'#text':    timeline.description,
        	'#format':  timeline.description_format,
          } %}        
        
          <div class="timeline-2-item">
          <div class="timeline-2-card timeline-2-bg-base text-white border-0">
          {% if timeline.time %}
            <div class="timeline-2-card-header py-2 timeline-2-bg-main rounded-0 border-0">
            {{ timeline.time|raw }}
            </div>
          {% endif %}
          <div class="timeline-2-card-body">
          {% if timeline.title %}
            <h3 class="timeline-2-card-title">{{ timeline.title|raw }}</h3>
          {% endif %}
          <div class="timeline-2-card-text">{{ tl_description }}</div>
          </div>
          </div>
          </div>
        {% endfor %}
    

    This appears to work successfully. From what I understand, the raw filter should be avoided if possible.

    I have made a copy of this file and included it directly in my theme, but I could make a patch (and include an update for all layout options, if that would be helpful.

  • πŸ‡ΊπŸ‡ΈUnited States bwoods
Production build 0.71.5 2024