Displaying inline svg in twig template

Created on 10 March 2021, almost 4 years ago
Updated 22 May 2024, 7 months ago

I'm trying to use SVG Image Field to upload svg files and then display them like inline svg, although there's a checkbox - Output svg inline I can't quite figure out how to output the filed value inside my paragraph twig template.
Has anyone use it like that and how are you adding it to your templates?

💬 Support request
Status

Closed: works as designed

Version

2.3

Component

Documentation

Created by

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.

  • Status changed to Closed: works as designed 7 months ago
  • 🇪🇨Ecuador jwilson3

    It is not common to have third and fourth level entity references all immediately loaded for rendering in Twig. How would we know which view mode to render?

    This functionality can best be achieved using the drupal_entity function from the Twig Tweak module, which is one of the primary reasons that module exists.

    {% set media_id = node.field_category.entity.field_svg.entity.id %}
    {% set media_view_mode = 'default' %}
    {{ drupal_entity('media', media_id, media_view_mode )}}
    

    Closing this as works as designed.

Production build 0.71.5 2024