From a20552db5bd589f54747843375b4e584ad85162a Mon Sep 17 00:00:00 2001 From: Stephen Mustgrave <smustgrave@gmail.com> Date: Fri, 3 Jan 2025 15:42:31 -0500 Subject: [PATCH] Issue #3433022: Separate class for container --- src/Plugin/Field/FieldFormatter/IframeDefaultFormatter.php | 2 +- templates/iframe.html.twig | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Plugin/Field/FieldFormatter/IframeDefaultFormatter.php b/src/Plugin/Field/FieldFormatter/IframeDefaultFormatter.php index 2413e4e..ae9014f 100644 --- a/src/Plugin/Field/FieldFormatter/IframeDefaultFormatter.php +++ b/src/Plugin/Field/FieldFormatter/IframeDefaultFormatter.php @@ -191,7 +191,7 @@ class IframeDefaultFormatter extends FormatterBase { $options['id'] = $options['name'] = $htmlid; // Append active class. - $options['class'] = $item->class ?? ''; + $options['class'] = $item->class ?? NULL; // Responsive start. Test class for iframe-responsive. $style = '#' . $htmlid . ' {' . $style . '}'; diff --git a/templates/iframe.html.twig b/templates/iframe.html.twig index 9d319d0..615044d 100644 --- a/templates/iframe.html.twig +++ b/templates/iframe.html.twig @@ -11,12 +11,13 @@ * - headerlevel: header level */ #} -<div{% if attributes.class is not empty %} class="{{ attributes.class }}"{% endif %}> +{% set iframe_container_classes = attributes.class|render %} +<div{% if iframe_container_classes %} class="{{ attributes.class }}"{% endif %}> {% if text is not empty %} <h{{ headerlevel ?? 3 }} class="iframe_title">{{ text }}</h{{ headerlevel ?? 3 }}> {% endif %} <style type="text/css">{{ style|raw }}</style> - <iframe {{ attributes }}> + <iframe {{ attributes|without('class') }}> {{ 'Your browser does not support iframes, but you can visit <a href=":url">@text</a>'|t({ ':url': src, '@text': text }) }} </iframe> </div> -- GitLab