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 -%}
|
2019-02-23 23:35:20 +01:00
|
|
|
{{ 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 %}
|