{% if figure.filename and figure.height and figure.width and (figure.alt or figure.caption) %}

{% if figure.caption %}
<figure>
  <div class="aspect-ratio-image post-image"
       style="width: {{ figure.width }}px; --aspect-w: {{ figure.width }}; --aspect-h: {{ figure.height }};">
    <img src="{{ figure.filename }}" alt="{{ figure.caption | striptags }}">
  </div>
  <figcaption>{{ figure.caption | safe }}</figcaption>
</figure>
{% else %}
<div class="aspect-ratio-image post-image"
     style="width: {{ figure.width }}px; --aspect-w: {{ figure.width }}; --aspect-h: {{ figure.height }};">
  <img src="{{ figure.filename }}" alt="{{ figure.caption | striptags }}">
</div>
{% endif %}

{% endif %}

{% if figure.filename and figure.height and figure.width and (figure.alt or figure.caption) %}

{% if figure.caption %}
<figure>
  <div class="aspect-ratio post-image"
       style="width: {{ figure.width }}px; --aspect-ratio-w: {{ figure.width }}; --aspect-ratio-h: {{ figure.height }};">
    <img src="{{ figure.filename }}" alt="{{ figure.caption | striptags }}">
  </div>
  <figcaption>{{ figure.caption | safe }}</figcaption>
</figure>
{% else %}
<div class="aspect-ratio post-image"
     style="width: {{ figure.width }}px; --aspect-ratio-w: {{ figure.width }}; --aspect-ratio-h: {{ figure.height }};">
  <img src="{{ figure.filename }}" alt="{{ figure.caption | striptags }}">
</div>
{% endif %}

{% endif %}

Fix incorrect usage of css-aspect-ratio module
Fix incorrect usage of css-aspect-ratio module
