🐛 fix: handle missing image metadata gracefully

main
welpo 2 years ago
parent be8ec45c35
commit b5b50cdefb
No known key found for this signature in database
GPG Key ID: A2F978CF4EC1F5A6

@ -7,7 +7,7 @@
<a rel="noopener noreferrer" target="_blank" href={{ page.extra.link_to }}>
{% endif %}
{% if page.extra.local_image %}
{% set meta = get_image_metadata(path=page.extra.local_image) %}
{% set meta = get_image_metadata(path=page.extra.local_image, allow_missing=true) %}
<img class="card-image" alt={{ page.extra.local_image }} src="{{ get_url(path=page.extra.local_image) }}" {% if meta.width %}width="{{ meta.width }}" {% endif %} {% if meta.height %}height="{{ meta.height }}" {% endif %}>
{% elif page.extra.remote_image %}
<img class="card-image" alt={{ page.extra.remote_image }} src="{{ page.extra.remote_image }}">

@ -1,2 +1,2 @@
{% set meta = get_image_metadata(path=src) %}
{% set meta = get_image_metadata(path=src, allow_missing=true) %}
<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,4 +1,4 @@
{% set light_meta = get_image_metadata(path=light_src) %}
{% set dark_meta = get_image_metadata(path=dark_src) %}
{% set light_meta = get_image_metadata(path=light_src, allow_missing=true) %}
{% set dark_meta = get_image_metadata(path=dark_src, allow_missing=true) %}
<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,2 +1,2 @@
{% set meta = get_image_metadata(path=src) %}
{% set meta = get_image_metadata(path=src, allow_missing=true) %}
<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…
Cancel
Save