feat(shortcodes): update image path retrieval and dimensions in shortcodes

- Use `get_url` function to generate correct image paths
- Retrieve image dimensions with `get_image_metadata` function
- Update shortcodes: dimmable_image, dual_theme_image, and invertible_image

These changes reduce layout shifts.
This commit is contained in:
welpo
2023-04-16 03:21:41 +02:00
parent 35cea7222c
commit b841969a8f
6 changed files with 16 additions and 11 deletions

View File

@@ -1 +1,2 @@
<img class="dimmable-image" {% if src %}src={{ src | safe | replace(from="$BASE_URL", to=config.base_url) }} {% endif %} {% if alt %}alt="{{ alt }}"{% endif %}/>
{% set meta = get_image_metadata(path=src) %}
<img class="dimmable-image" src="{{ get_url(path=src) }}" {% if alt %}alt="{{ alt }}" {% endif %} {% if meta.width %}width="{{ meta.width }}" {% endif %} {% if meta.height %}height="{{ meta.height }}" {% endif %}/>