custom/plugins/KmPitchPrint/src/Resources/views/storefront/utilities/thumbnail.html.twig line 1

Open in your IDE?
  1. {# in diesen Routes werden die webp-Grafiken nicht verwendet (PP-Previews) #}
  2. {% set except_webp_routes = [
  3.     'frontend.checkout.cart.page',
  4.     'frontend.checkout.finish.page',
  5.     'frontend.checkout.confirm.page',
  6.     'frontend.checkout.register.page',
  7.     'frontend.account.edit-order.page',
  8.     'frontend.wishlist.page',
  9.     'km.ticket.form'
  10. ] %}
  11. {% if activeRoute in except_webp_routes %}
  12.  {% sw_include '@KmPritchPrint/storefront/utilities/thumbnail-km-pp.html.twig'  with {
  13.         media: media
  14.     }%}
  15. {% else %}    
  16.     {% block thumbnail_utility %}{% apply spaceless %}
  17.     {% if attributes is not defined %}
  18.         {% set attributes = {} %}
  19.     {% endif %}
  20.     {% if attributes.class %}
  21.         {% set attributes = attributes|merge({'class': 'weedesign-webp ' ~ attributes.class}) %}
  22.     {% else %}
  23.         {% set attributes = attributes|merge({'class': 'weedesign-webp'}) %}
  24.     {% endif %}
  25.     {% if attributes.alt is not defined and media.translated.alt is defined %}
  26.         {% set attributes = attributes|merge({'alt': media.translated.alt}) %}
  27.     {% endif %}
  28.     {% if attributes.title is not defined and media.translated.title is defined %}
  29.         {% set attributes = attributes|merge({'title': media.translated.title}) %}
  30.     {% endif %}
  31.     {% set metaProportion = media.metaData %}
  32.     {% if media.thumbnails|length > 0 %}
  33.         {% if minSize > 0 %} {# Die Slider wurden unscharf angezeigt, weil Höhe zu gering. minSize wird in cms-element-solid-ase-content-slider.html.twig gesetzt #}
  34.             {% set thumbnails = media.thumbnails|filter((v) => v.width <= metaProportion.width && v.width > minSize )|sort((a, b) => a.width <=> b.width)|reverse %}
  35.         {% else %}
  36.             {% set thumbnails = media.thumbnails|filter((v) => v.width <= metaProportion.width )|sort((a, b) => a.width <=> b.width)|reverse %}
  37.         {% endif %}
  38.         {% if thumbnails %}
  39.             {% set srcsetValue %}{% apply spaceless %}
  40.                 {{ media|weedesign_images2webp_webp_url_media }} {{ thumbnails|first.width + 1 }}w, 
  41.                 {% for thumbnail in thumbnails %}
  42.                     {{ thumbnail|weedesign_images2webp_webp_url_thumbnail }} {{ thumbnail.width - 10 }}w{% if not loop.last %}, {% endif %}
  43.                 {% endfor %}
  44.             {% endapply %}{% endset %}
  45.         {% endif %}
  46.     {% endif %}
  47.     {% set ratio = metaProportion.width ~ '/' ~ metaProportion.height %}
  48.     {% set inlineStyle = "aspect-ratio:" ~ ratio ~ ";" %}
  49.     {% if attributes.style %}
  50.         {% set attributes = attributes|merge({'style': inlineStyle ~ attributes.style}) %}
  51.     {% else %}
  52.         {% set attributes = attributes|merge({'style': inlineStyle}) %}
  53.     {% endif %}
  54.     {% block thumbnail_utility_img %}
  55.         {% set src = media|weedesign_images2webp_webp_url_media %}
  56.         <img src="{{ src }}"
  57.             {% if srcsetValue != "" %}
  58.                 srcset="{{ srcsetValue }}"
  59.             {% endif %}
  60.             {% for key, value in attributes %}
  61.                 {{ key }}="{{ value }}"
  62.                 {% if key == 'itemprop' %}
  63.                     content="{{ media|weedesign_images2webp_webp_url_media }}"
  64.                 {% endif %}
  65.             {% endfor %}
  66.         />
  67.     {% endblock %}
  68. {% endapply %}{% endblock %}
  69. {% endif %}