vendor/frosh/platform-thumbnail-processor/src/Resources/views/storefront/utilities/thumbnail.html.twig line 1

Open in your IDE?
  1. {% block thumbnail_utility %}{% apply spaceless %}
  2.     {% if attributes is not defined %}
  3.         {% set attributes = {} %}
  4.     {% endif %}
  5.     {% if attributes.class %}
  6.         {% set attributes = attributes|merge({'class': 'frosh-proc lazyload ' ~ attributes.class}) %}
  7.     {% else %}
  8.         {% set attributes = attributes|merge({'class': 'frosh-proc lazyload'}) %}
  9.     {% endif %}
  10.     {% if attributes.alt is not defined and media.translated.alt is defined %}
  11.         {% set attributes = attributes|merge({'alt': media.translated.alt}) %}
  12.     {% endif %}
  13.     {% if attributes.title is not defined and media.translated.title is defined %}
  14.         {% set attributes = attributes|merge({'title': media.translated.title}) %}
  15.     {% endif %}
  16.     {% set metaProportion = media.metaData %}
  17.     {% if media.thumbnails|length > 0 %}
  18.         {% set thumbnails = media.thumbnails|filter((v) => v.width <= metaProportion.width)|sort((a, b) => a.width <=> b.width)|reverse %}
  19.         {% if thumbnails %}
  20.             {# generate srcset with all available thumbnails #}
  21.             {% set srcsetValue %}{% apply spaceless %}
  22.                 {{ 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 %}
  23.             {% endapply %}{% endset %}
  24.         {% endif %}
  25.     {% endif %}
  26.     {% set ratio = metaProportion.width ~ '/' ~ metaProportion.height %}
  27.     {% set inlineStyle = "aspect-ratio:" ~ ratio ~ ";" %}
  28.     {% if attributes.style %}
  29.         {% set attributes = attributes|merge({'style': inlineStyle ~ attributes.style}) %}
  30.     {% else %}
  31.         {% set attributes = attributes|merge({'style': inlineStyle}) %}
  32.     {% endif %}
  33.     {% block thumbnail_utility_img %}
  34.         {% if src is not defined %}
  35.             {% set src = 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==' %}
  36.         {% endif %}
  37.         <img src="{{ src }}"
  38.             data-src="{{ media.url|frosh_encode_url }}"
  39.             {% if srcsetValue %}
  40.                 data-srcset="{{ srcsetValue }}"
  41.                 data-sizes="auto"
  42.                 data-aspectratio="{{ ratio }}"
  43.                 data-parent-fit="contain"
  44.             {% endif %}
  45.             {% for key, value in attributes %}
  46.                 {{ key }}="{{ value }}"
  47.                 {% if key == 'itemprop' %}
  48.                     content="{{ media.url|frosh_encode_url }}"
  49.                 {% endif %}
  50.             {% endfor %}
  51.         />
  52.     {% endblock %}
  53. {% endapply %}{% endblock %}