✨ 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.main
parent
35cea7222c
commit
b841969a8f
Binary file not shown.
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 79 KiB |
Binary file not shown.
Before Width: | Height: | Size: 46 KiB After Width: | Height: | Size: 51 KiB |
@ -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 %}/>
|
||||
|
@ -1,2 +1,4 @@
|
||||
<img src="{{ light_src | safe | replace(from="$BASE_URL" , to=config.base_url) }}" {% if alt %}alt="{{ alt }}" {% endif %} class="img-light">
|
||||
<img src="{{ dark_src | safe | replace(from="$BASE_URL" , to=config.base_url) }}" {% if alt %}alt="{{ alt }}" {% endif %} class="img-dark">
|
||||
{% set light_meta = get_image_metadata(path=light_src) %}
|
||||
{% set dark_meta = get_image_metadata(path=dark_src) %}
|
||||
<img src="{{ get_url(path=light_src) }}" {% if alt %}alt="{{ alt }}" {% endif %} {% if light_meta.width %}width="{{ light_meta.width }}" {% endif %} {% if light_meta.height %}height="{{ light_meta.height }}" {% endif %} class="img-light">
|
||||
<img src="{{ get_url(path=dark_src) }}" {% if alt %}alt="{{ alt }}" {% endif %} {% if dark_meta.width %}width="{{ dark_meta.width }}" {% endif %} {% if dark_meta.height %}height="{{ dark_meta.height }}" {% endif %} class="img-dark">
|
||||
|
@ -1 +1,2 @@
|
||||
<img class="invertible-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="invertible-image" {% if src %}src="{{ get_url(path=src) }}" {% endif %} {% if alt %}alt="{{ alt }}" {% endif %} {% if meta.width %}width="{{ meta.width }}" {% endif %} {% if meta.height %}height="{{ meta.height }}" {% endif %}/>
|
||||
|
Loading…
Reference in New Issue