forget-cancellare-vecchi-toot/templates/lib/picture.html

20 lines
568 B
HTML
Raw Normal View History

2017-08-24 15:39:11 +02:00
{% macro picture(st, basename, widths, formats, sizes=None, alt='') -%}
{% if not sizes %}
{% set sizes = '{}px'.format(widths[0]) %}
{% endif %}
<picture>
{%- for format in formats %}
<source type='image/{{format}}' sizes='{{sizes}}' srcset="
{%- for width in widths -%}
{{ st('{}-{}.{}'.format(basename, width, format)) }} {{width}}w
{%- if not loop.last %},{% endif %}
2017-08-24 15:39:11 +02:00
{%- endfor -%}
"/>
{% endfor %}
<img src="{{ st('{}-{}.{}'.format(basename, widths[0], formats[-1])) }}" alt="{{alt}}" />
</picture>
{%- endmacro %}