Verwendung: Template für Bild

Miriam's Avatar

Miriam

13 Jul, 2023 04:20 PM

Produkt: Tao Contao
Contao-Version: 5.1.2

Hallo,
Welches Template ist dafür zuständig, um ein Bild in einem Textelement darzustellen?
Normalerweise wäre dies ja "image.html5", dieses findet unter Verwendung des Themes TAO aber leider keine Beachtung.

(Ich würde gerne das <figure>-Tag um die Klasse einer Bildgröße erweitern.)

Vielen Dank!

  1. Support Staff 1 Posted by RockSolid Theme... on 14 Jul, 2023 12:57 PM

    RockSolid Themes's Avatar

    Vielen Dank für Ihre Frage.

    Für Inhaltselemente setzt Contao 5 anstatt der .html5-Dateien .html.twig-Templates ein.

    Sie können die Bildausgabe des Text-Elements abändern indem Sie ein Template unter templates/content_element/text.html.twig erstellen.

    Ich würde gerne das <figure>-Tag um die Klasse einer Bildgröße erweitern.

    Die CSS-Klasse der Bildgröße wird standardmäßig dem <img>-Element zugeordnet. Um diese Klasse dem <figure> hinzuzufügen können Sie folgenden Twig-Code verwenden:

    {% extends "@Contao/content_element/text.html.twig" %}
    
    {%
        set figure_attributes = attrs({
            class: image.image.img.class|default,
        }).mergeWith(figure_attributes|default)
    %}
    
  2. 2 Posted by Miriam on 14 Jul, 2023 01:38 PM

    Miriam's Avatar

    Super, hat einwandfrei funktioniert!
    Vielen Dank für die schnelle Hilfe!

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac