{# Image-rendering macro, used both by templates (directly via import)
   and indirectly by the `img` shortcode (which forwards to it). #}

{% macro render(src, width, alt="", class="") %}
  {%- set source_path = "static/images/" ~ src -%}
  {%- set resized = resize_image(path=source_path, width=width, op="fit_width", quality=85) -%}
  <img
    src="{{ resized.url }}"
    width="{{ resized.width }}"
    height="{{ resized.height }}"
    alt="{{ alt }}"
    {%- if class %} class="{{ class }}"{% endif %}
    loading="lazy"
  >
{% endmacro render %}
