Render image in Bard with custom template

When I embed an image within a bard, the image can be rendered along with the text using the following code:

{{ content }}
    {{ if type == "text" }}
        <div class="text">
            {{ text }}
        </div>
    {{ /if }}
{{ /content }}

The image then gets rendered using an img tag:

<div class="text">
    <img src="..." alt>
</div>

However, I would like to customize how the image is rendered (for example, to add a custom class, or wrap it within another tag).

One idea I had was to create a bard set that only contains an asset field. I could disable the regular way of embedding and image and force the user to use the new bard set. This way, I can apply custom rendering to it:

<!-- untested -->
{{ content }}
    {{ if type == "image_set" }}
        <div class="custom-img-wrapper">
            <img src="{{ url }}" alt="{{ alt }}" class="custom-img-class">
        </div>
    {{ /if }}
{{ /content }}

However, I would like to avoid this if possible, because it is confusing for the users that this one bard works differently than all the others. Is there a way to customize the rendering of embedded images?

>>>>>>> Unanswered <<<<<<<
3 Replies
3 Followers