{% block thumbnail_utility %}{% apply spaceless %}
{% if attributes is not defined %}
{% set attributes = {} %}
{% endif %}
{% if attributes.class %}
{% set attributes = attributes|merge({'class': 'frosh-proc lazyload ' ~ attributes.class}) %}
{% else %}
{% set attributes = attributes|merge({'class': 'frosh-proc lazyload'}) %}
{% endif %}
{% if attributes.alt is not defined and media.translated.alt is defined %}
{% set attributes = attributes|merge({'alt': media.translated.alt}) %}
{% endif %}
{% if attributes.title is not defined and media.translated.title is defined %}
{% set attributes = attributes|merge({'title': media.translated.title}) %}
{% endif %}
{% set metaProportion = media.metaData %}
{% if media.thumbnails|length > 0 %}
{% set thumbnails = media.thumbnails|filter((v) => v.width <= metaProportion.width)|sort((a, b) => a.width <=> b.width)|reverse %}
{% if thumbnails %}
{# generate srcset with all available thumbnails #}
{% set srcsetValue %}{% apply spaceless %}
{{ media.url|frosh_encode_url }} {{ thumbnails|first.width + 1 }}w, {% for thumbnail in thumbnails %}{{ thumbnail.url|frosh_encode_url }} {{ thumbnail.width }}w{% if not loop.last %}, {% endif %}{% endfor %}
{% endapply %}{% endset %}
{% endif %}
{% endif %}
{% set ratio = metaProportion.width ~ '/' ~ metaProportion.height %}
{% set inlineStyle = "aspect-ratio:" ~ ratio ~ ";" %}
{% if attributes.style %}
{% set attributes = attributes|merge({'style': inlineStyle ~ attributes.style}) %}
{% else %}
{% set attributes = attributes|merge({'style': inlineStyle}) %}
{% endif %}
{% block thumbnail_utility_img %}
{% if src is not defined %}
{% set src = 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==' %}
{% endif %}
<img src="{{ src }}"
data-src="{{ media.url|frosh_encode_url }}"
{% if srcsetValue %}
data-srcset="{{ srcsetValue }}"
data-sizes="auto"
data-aspectratio="{{ ratio }}"
data-parent-fit="contain"
{% endif %}
{% for key, value in attributes %}
{{ key }}="{{ value }}"
{% if key == 'itemprop' %}
content="{{ media.url|frosh_encode_url }}"
{% endif %}
{% endfor %}
/>
{% endblock %}
{% endapply %}{% endblock %}