feat: check if image exists before caching optimized version
This commit is contained in:
parent
cb6b5dbd8e
commit
f0f1c0aaab
9 changed files with 101 additions and 55 deletions
|
@ -37,10 +37,11 @@
|
|||
'lazy'
|
||||
{%- endif -%}
|
||||
{%- endcapture -%}
|
||||
{% capture fallbackIcon %}{% tablericon icon alt %}{% endcapture %}
|
||||
{% if imageMaxWidth %}
|
||||
{% image item.image, alt, '', loadingStrategy, imageMaxWidth %}
|
||||
{% image item.image, alt, '', loadingStrategy, shape, fallbackIcon, imageMaxWidth %}
|
||||
{% else %}
|
||||
{% image item.image, alt, '', loadingStrategy %}
|
||||
{% image item.image, alt, '', loadingStrategy, shape, fallbackIcon, 1248 %}
|
||||
{% endif %}
|
||||
</div>
|
||||
</a>
|
||||
|
|
|
@ -6,12 +6,9 @@
|
|||
<div class="comment__wrapper--interior flex--centered">
|
||||
<a href={{mention.url}}>
|
||||
<div class="avatar__wrapper flex--centered">
|
||||
<img
|
||||
src="{{ mention.author.photo }}"
|
||||
alt="{{ mention.author.name | escape }}"
|
||||
class="avatar__image"
|
||||
loading="lazy"
|
||||
onerror="this.onerror=null; this.src='/assets/img/icons/user.webp'" />
|
||||
{% capture authorAlt %}{{ mention.author.name | escape }}{% endcapture %}
|
||||
{% capture fallbackIcon %}{% tablericon "user" authorAlt %}{% endcapture %}
|
||||
{% image mention.author.photo, authorAlt, 'avatar__image', 'lazy', 'rounded', fallbackIcon %}
|
||||
</div>
|
||||
</a>
|
||||
<div class="comment">
|
||||
|
|
|
@ -11,12 +11,9 @@
|
|||
{% for mention in mentions[type] %}
|
||||
<a href={{mention.url}}>
|
||||
<div class="avatar__wrapper flex--centered">
|
||||
<img
|
||||
src="{{ mention.author.photo }}"
|
||||
alt="{{ mention.author.name | escape }}"
|
||||
class="avatar__image"
|
||||
loading="lazy"
|
||||
onerror="this.onerror=null; this.src='/assets/img/icons/user.webp'" />
|
||||
{% capture authorAlt %}{{ mention.author.name | escape }}{% endcapture %}
|
||||
{% capture fallbackIcon %}{% tablericon "user" authorAlt %}{% endcapture %}
|
||||
{% image mention.author.photo, authorAlt, 'avatar__image', 'lazy', 'rounded', fallbackIcon %}
|
||||
</div>
|
||||
</a>
|
||||
{% endfor %}
|
||||
|
|
Reference in a new issue