add relative path support for shortcodes

This commit is contained in:
Sandro Stikić 2024-07-20 11:24:05 +08:00
parent c620187811
commit 4bd51a529b
No known key found for this signature in database
2 changed files with 15 additions and 8 deletions

View file

@ -2,7 +2,7 @@
{# If the image's URL is internal to the site... #}
{% if src is not starting_with("http") %}
{# ... then prepend the site's base URL to the image's URL. #}
{% set src = config.base_url ~ src %}
{% set src = get_url(path=page.colocated_path ~ src) %}
{% endif %}
<img src="{{ src | safe }}"{% if alt %} alt="{{ alt }}"{% endif %} class="{% if position %}{{ position }}{% else -%} center {%- endif %}" {%- if style %} style="{{ style | safe }}" {%- endif %} decoding="async" loading="lazy"/>
<img src="{{ src | safe }}"{% if alt %} alt="{{ alt }}" title="{{ alt }}"{% endif %} class="{% if position %}{{ position }}{% else -%} center {%- endif %}" {%- if style %} style="{{ style | safe }}" {%- endif %} decoding="async" loading="lazy"/>
{% endif %}