mkdocs-glightbox icon indicating copy to clipboard operation
mkdocs-glightbox copied to clipboard

Can `img` elements in templates be supported?

Open jaywhj opened this issue 2 months ago • 0 comments

I have some html pages generated with templates, and the img elements inside the templates are not recognized by glightbox, is it possible to support the img elements in the templates?

    {#- Render authors #}
    {%- if page.meta.document_dates_authors %}
        {%- set icon = 'doc_author' if page.meta.document_dates_authors|length == 1 else 'doc_authors' %}
    <span class="material-icons" data-icon="{{ icon }}"></span>
    <div class="avatar-group">
        {%- for author in page.meta.document_dates_authors %}
            {%- set tooltip %}
                {%- if author.url -%}
                    <a href="{{ author.url }}" target="_blank">{{ author.name }}</a>
                {%- elif author.email -%}
                    <a href="mailto:{{ author.email }}">{{ author.name }}</a>
                {%- else -%}
                    {{ author.name }}
                {%- endif -%}
            {%- endset %}
        <div class="avatar-wrapper" data-name="{{ author.name }}" data-tippy-content data-tippy-raw='{{ tooltip }}'>
            <span class="avatar-text"></span>
            <img class="avatar" src="{{ author.avatar }}" onerror="this.style.display='none'" />
        </div>
        {%- endfor %}
    </div>
    {%- endif %}

I looked at the source code, and it should be that the timing of the img wrapping needs to be put after the template rendering, so that it will work.

jaywhj avatar Nov 18 '25 06:11 jaywhj