Vor dem Update auf 5.3 hatte ich folgenden HTML-Code für YouTube Videos:
HTML-Code:
<div class="ce_youtube block">
<figure class="video_container">
<div class="responsive ratio-169">
<iframe width="640" height="360" data-name="youtube" data-src="https://www.youtube.com/embed/XYZ" allow="autoplay; encrypted-media; picture-in-picture; fullscreen" allowfullscreen></iframe>
</div>
</figure>
</div>
Der Consent Manager hat dabei den Inhalt blockiert, bis der Benutzer zugestimmt hatte. Deshalb war die Quelle im Attribut data-src.
Wie kann ich das im TWIG-Template von Contao 5.3 umsetzen?
Ich habe bereits folgendes probiert, ohne eine Änderung zu sehen:
Code:
templates/content_element/youtube.html.twig
{% extends "@Contao/content_element/youtube.html.twig" %}
{#
** Add changes to the base template here. **
Hint: Try adjusting blocks and attributes instead of
overwriting the whole template. This way your version
can remain compatible with future changes to the base
template as well as adjustments made by extensions.
Currently available blocks:
"splash_screen_text", "splash_screen_component",
"splash_screen_button_content",
"splash_screen_content", "splash_screen_script",
"picture_component", "image", "sources", "source",
"schema_org", "content", "iframe",
"video_caption", "headline_component",
"headline_attributes", "headline_inner",
"wrapper", "wrapper_tag", "attributes", "inner",
"metadata", "style", "script"
Example:
{% block splash_screen_text %}
{{ parent() }}
My additional content for 'splash_screen_text'…
{% endblock %}
#}
{% set iframe_attrs = attrs()
.set('allow', 'autoplay; encrypted-media; picture-in-picture; fullscreen')
.set('data-name', 'youtube')
.mergeWith(iframe_attrs|default)
%}