Remove metadata check to support avif and reduce CLS

This commit is contained in:
blaine-t 2024-09-09 22:38:22 -05:00
parent 7e0f022c92
commit b5d84f5435
No known key found for this signature in database
GPG key ID: 8D281DF6BDB25B4A
3 changed files with 3 additions and 7 deletions

View file

@ -18,10 +18,9 @@
<a rel="{{ rel_attributes }}" {{ blank_target }} href="{{ target_url }}" class="card">
<div>
{% if page.extra.local_image %}
{% set meta = get_image_metadata(path=page.extra.local_image, allow_missing=true) %}
<img loading="lazy" 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 %}>
<img loading="lazy" class="card-image" alt="{{ page.extra.local_image }}" src="{{ get_url(path=page.extra.local_image) }}" width="600px" height="600px">
{% elif page.extra.remote_image %}
<img loading="lazy" class="card-image" alt="{{ page.extra.remote_image }}" src="{{ page.extra.remote_image }}">
<img loading="lazy" class="card-image" alt="{{ page.extra.remote_image }}" src="{{ page.extra.remote_image }}" width="600px" height="600px">
{% else %}
<div class="card-image-placeholder"></div>
{% endif %}

View file

@ -14,8 +14,7 @@
{%- set image_path = get_url(path=header.img, trailing_slash=false) | safe -%}
{%- endif -%}
<div id="image-container-home">
{% set meta = get_image_metadata(path=header.img, allow_missing=true) %}
<img fetchpriority="high" alt="{{ header.img_alt | default(value="the owner") }}" id="banner-home-img" src="{{ image_path }}" {% if meta.width %}width="{{ meta.width }}" {% endif %} {% if meta.height %}height="{{ meta.height }}" {% endif %} />
<img fetchpriority="high" alt="{{ header.img_alt | default(value="the owner") }}" id="banner-home-img" src="{{ image_path }}" width="192px" height="192px" />
</div>
{%- endif -%}
</div>

View file

@ -4,11 +4,9 @@
{%- else -%}
{%- set colocated_path = page.colocated_path | default(value="") -%}
{%- set relative_path = colocated_path ~ src -%}
{%- set meta = get_image_metadata(path=relative_path, allow_missing=true) -%}
{#- Fallback to absolute path if relative path doesn't work -#}
{%- if not meta -%}
{%- set meta = get_image_metadata(path=src, allow_missing=true) -%}
{%- set image_url = get_url(path=src) -%}
{%- else -%}
{%- set image_url = get_url(path=relative_path) -%}