custom/plugins/zenitPlatformHorizon/src/Resources/views/storefront/element/cms-element-image-gallery.html.twig line 1

Open in your IDE?
  1. {% sw_extends '@Storefront/storefront/element/cms-element-image-gallery.html.twig' %}
  2. {% block element_image_gallery %}
  3.     {# TODO: Check again as soon as Shopware solves the bug in the original code itself. #}
  4.     {% if element.fieldConfig is defined and element.data is defined %}
  5.         {% if not config %}
  6.             {% set config = element.fieldConfig.elements %}
  7.         {% endif %}
  8.     {% endif %}
  9.     {{ parent() }}
  10. {% endblock %}
  11. {% block element_image_gallery_alignment %}
  12.     {% set magnifierOptions = magnifierOptions|merge({
  13.         'zoomFactor': theme_config('zen-product-gallery-slider-zoom-factor')?: 3
  14.     }) %}
  15.     {{ parent() }}
  16. {% endblock %}
  17. {% block element_image_gallery_inner_wrapper %}
  18.     {% if config('core.cart.wishlistEnabled') and page.product.id is not empty %}
  19.         {# ... @zenit fallback for older child-themes without this config #}
  20.         {% set productDetailWishlistPosition = theme_config('zen-product-details-wishlist-position') ?: 'default' %}
  21.         {% if productDetailWishlistPosition is same as ('gallery') %}
  22.             {% sw_include '@Storefront/storefront/component/product/card/wishlist.html.twig' with {
  23.                 showText: false,
  24.                 size: 'xl',
  25.                 productId: page.product.id,
  26.                 tooltip: true,
  27.                 tooltipPlacement: 'left'
  28.             } %}
  29.         {% endif %}
  30.     {% endif %}
  31.     {{ parent() }}
  32. {% endblock %}
  33. {% block element_image_gallery_slider_dots %}
  34.     {# ... add aria-label #}
  35.     {% if imageCount > 1 and navigationDots %}
  36.         <div class="base-slider-dots {% if imageCount > maxItemsToShowNav %} hide-dots{% elseif imageCount > maxItemsToShowMobileNav %} hide-dots-mobile{% endif %}">
  37.             {% block element_image_gallery_slider_dots_buttons %}
  38.                 {% for image in mediaItems %}
  39.                     {% block element_image_gallery_slider_dots_button %}
  40.                         <button class="base-slider-dot"
  41.                                 aria-label="base-slider-dot-{{ loop.index }}"
  42.                                 data-nav-dot="{{ loop.index }}"
  43.                                 tabindex="-1"></button>
  44.                     {% endblock %}
  45.                 {% endfor %}
  46.             {% endblock %}
  47.         </div>
  48.     {% endif %}
  49. {% endblock %}
  50. {% block element_image_gallery_inner %}
  51.     {# ... add nav to false, otherwise the tns-nav would appear when there are no thumbnails #}
  52.     {% if hideThumbnails is same as (true) %}
  53.         {% set gallerySliderOptions = gallerySliderOptions|replace_recursive({
  54.             slider: {
  55.                 nav: false
  56.             }
  57.         }) %}
  58.     {% endif %}
  59.     {# too many underneath thumbs or slider dots make them hard to see #}
  60.     {% set maxItemsToShowMobileNav = theme_config('zen-max-items-to-show-mobile-nav') ?: 5 %}
  61.     {% set maxItemsToShowNav = theme_config('zen-max-items-to-show-nav') ?: 8 %}
  62.     <div class="row gallery-slider-row{% if imageCount == 1 %} is-single-image{% else %} is-loading{% endif %} js-gallery-zoom-modal-container"
  63.         {% if zoom %}
  64.             data-magnifier="true"
  65.         {% endif %}
  66.         {% if magnifierOptions|length > 0 %}
  67.             data-magnifier-options='{{ magnifierOptions|json_encode|raw }}'
  68.         {% endif %}
  69.         {% if imageCount > 1 %}
  70.             data-gallery-slider="true"
  71.             data-gallery-slider-options='{{ gallerySliderOptions|json_encode }}'
  72.         {% endif %}
  73.         {# ... @zenit add galleryMode #}
  74.         {% if galleryMode is same as ('scroller') and isProduct %}
  75.             data-zen-gallery-scroller="true"
  76.         {% endif %}
  77.         {% if galleryMode is same as ('grid') and isProduct %}
  78.             data-zen-gallery-grid="true"
  79.         {% endif %}>
  80.         {{ block('element_image_gallery_inner_col') }}
  81.         {{ block('element_image_gallery_inner_thumbnails_col') }}
  82.         {{ block('element_image_gallery_inner_zoom_modal_wrapper') }}
  83.     </div>
  84. {% endblock %}
  85. {% block element_image_gallery_inner_item %}
  86.     {# ... add container .gallery-slider-item-wrap #}
  87.     <div class="gallery-slider-item-container">
  88.         <div class="gallery-slider-item-wrap">
  89.             {% if theme_config('zen-product-gallery-fallback-image-title') is not same as ('default') %}
  90.                 {% set fallbackImageTitle = image.fileName %}
  91.             {% endif %}
  92.             <div class="gallery-slider-item is-{{ displayMode }} js-magnifier-container"{% if minHeight and  (displayMode == "cover" or displayMode == "contain" ) %} style="min-height: {{ minHeight }}"{% endif %}>
  93.                 {% set attributes = {
  94.                     'class': 'img-fluid gallery-slider-image magnifier-image js-magnifier-image',
  95.                     'alt': (image.translated.alt ?: fallbackImageTitle),
  96.                     'title': (image.translated.title ?: fallbackImageTitle),
  97.                     'data-full-image': image.url
  98.                 } %}
  99.                 {% if displayMode == 'cover' or displayMode == 'contain' %}
  100.                     {% set attributes = attributes|merge({ 'data-object-fit': displayMode }) %}
  101.                 {% endif %}
  102.                 {% if isProduct %}
  103.                     {% set attributes = attributes|merge({ 'itemprop': 'image' }) %}
  104.                 {% endif %}
  105.                 {# ... enables lazy loading for images,
  106.                 but only on cover mode, because of JS height calculation #}
  107.                 {% if displayMode == 'cover' %}
  108.                     {% if config('zenitPlatformHorizon.config.lazyloading') %}
  109.                         {% set attributes = attributes|merge({ 'loading': 'lazy' }) %}
  110.                     {% endif %}
  111.                 {% endif %}
  112.                 {% sw_thumbnails 'gallery-slider-image-thumbnails' with {
  113.                     media: image,
  114.                 } %}
  115.             </div>
  116.         </div>
  117.     </div>
  118. {% endblock %}
  119. {% block element_image_gallery_inner_single %}
  120.     <div class="gallery-slider-single-image is-{{ displayMode }}{% if imageCount <= 0 %} is-placeholder{% endif %} js-magnifier-container"{% if minHeight %} style="min-height: {{ imageCount > 0 ? minHeight : '430px' }}"{% endif %}>
  121.         {% if theme_config('zen-product-gallery-fallback-image-title') is not same as ('default') %}
  122.             {% set fallbackImageTitle = mediaItems|first.fileName %}
  123.         {% endif %}
  124.         {% if imageCount > 0 %}
  125.             {% set attributes = {
  126.                 'class': 'img-fluid gallery-slider-image magnifier-image js-magnifier-image',
  127.                 'alt': (mediaItems|first.translated.alt ?: fallbackImageTitle),
  128.                 'title': (mediaItems|first.translated.title ?: fallbackImageTitle),
  129.                 'data-full-image': mediaItems|first.url
  130.             } %}
  131.             {% if displayMode == 'cover' or displayMode == 'contain' %}
  132.                 {% set attributes = attributes|merge({ 'data-object-fit': displayMode }) %}
  133.             {% endif %}
  134.             {% if isProduct %}
  135.                 {% set attributes = attributes|merge({ 'itemprop': 'image' }) %}
  136.             {% endif %}
  137.             {# ... enables lazy loading for images #}
  138.             {% if config('zenitPlatformHorizon.config.lazyloading') %}
  139.                 {% set attributes = attributes|merge({ 'loading': 'lazy' }) %}
  140.             {% endif %}
  141.             {% sw_thumbnails 'gallery-slider-image-thumbnails' with {
  142.                 media: mediaItems|first
  143.             } %}
  144.         {% else %}
  145.             {% sw_icon 'placeholder' style {
  146.                 'size': 'fluid'
  147.             } %}
  148.         {% endif %}
  149.     </div>
  150. {% endblock %}
  151. {% block element_image_gallery_inner_thumbnails_col %}
  152.     {% if hideThumbnails is not same as (true) %}
  153.         {{ parent() }}
  154.     {% endif %}
  155. {% endblock %}
  156. {% block element_image_gallery_inner_thumbnails_item_inner %}
  157.     {% if theme_config('zen-product-gallery-fallback-image-title') is not same as ('default') %}
  158.         {% set fallbackImageTitle = image.fileName %}
  159.     {% endif %}
  160.     {{ parent() }}
  161. {% endblock %}
  162. {% block element_image_gallery_inner_zoom_modal_slider_item_image %}
  163.     {% if theme_config('zen-product-gallery-fallback-image-title') is not same as ('default') %}
  164.         {% set fallbackImageTitle = image.fileName %}
  165.     {% endif %}
  166.     {{ parent() }}
  167. {% endblock %}