custom/plugins/zenitPlatformStratus/src/Resources/views/storefront/component/product/card/zen-cover-switch.html.twig line 1

Open in your IDE?
  1. {% block zen_component_product_box_image_switch_inner %}
  2.     {# if there are more than one image #}
  3.     {% if product.media.elements is defined and product.media.elements|length > 1 and theme_config('zen-product-listing-card-img-switch') is not same as ('none') %}
  4.         {% set productMediaLength = product.media.elements|length %}
  5.         {% set productMediaPosition = productMediaLength %}
  6.         {% set coverSwitch = [] %}
  7.         {# increase productMediaPosition if image.position is > product.media.elements #}
  8.         {% for image in product.media.elements %}
  9.             {% if product.cover.media.id != image.media.id and image.position > productMediaLength %}
  10.                 {% set productMediaLength = image.position %}
  11.                 {% set productMediaPosition = image.position + 1 %}
  12.             {% endif %}
  13.         {% endfor %}
  14.         {# get image with lowest position #}
  15.         {% for image in product.media.elements %}
  16.             {% if product.cover.media.id != image.media.id and image.position < productMediaPosition %}
  17.                 {% set coverSwitch = image.media %}
  18.                 {% set productMediaPosition = image.position %}
  19.             {% endif %}
  20.         {% endfor %}
  21.     {% endif %}
  22.     {% if coverSwitch.url %}
  23.         {% set animationOptions = {
  24.             parentTrigger: '.product-image-wrapper',
  25.         } %}
  26.         {% set attributes = {
  27.             'class': 'cover-switch product-image is-'~displayMode,
  28.             'data-zen-cover-switch': 'true',
  29.             'data-zen-animation-options': animationOptions|json_encode,
  30.             'alt': (coverSwitch.translated.alt ?: name),
  31.             'title': (coverSwitch.translated.title ?: name)
  32.         } %}
  33.         {# ... enables lazy loading for images #}
  34.         {% if config('zenitPlatformStratus.config.lazyloading') %}
  35.             {% set attributes = attributes|merge({ 'loading': 'lazy' }) %}
  36.         {% endif %}
  37.         {% if displayMode == 'cover' or displayMode == 'contain' %}
  38.             {% set attributes = attributes|merge({ 'data-object-fit': displayMode }) %}
  39.         {% endif %}
  40.         {% sw_thumbnails 'product-image-thumbnails' with {
  41.             media: coverSwitch,
  42.             sizes: sizes
  43.         } %}
  44.     {% endif %}
  45. {% endblock %}