themes/BootstrapChildTheme/SyliusShopBundle/views/Product/Show/_images.html.twig line 1

Open in your IDE?
  1. <div id="product-image">
  2.     {% if product.imagesByType('main') is not empty %}
  3.         {% set source_path = product.imagesByType('main').first.path %}
  4.         {# {% set original_path = source_path|imagine_filter('sylius_shop_product_original') %} #}
  5.         {# {% set path = source_path | imagine_filter('my_original_webp') %} #}
  6.         {% set final_path = source_path|imagine_filter(filter|default('sylius_shop_product_original')) %}
  7.         {% set final_path_webp = source_path|imagine_filter('my_original_webp') %}
  8.     {% elseif product.images.first %}
  9.         {% set source_path = product.images.first.path %}
  10.         {% set original_path = source_path|imagine_filter('sylius_shop_product_original') %}
  11.         {# {% set path = source_path|imagine_filter(filter|default('sylius_shop_product_original')) %} #}
  12.         {% set final_path = source_path|imagine_filter(filter|default('sylius_shop_product_original')) %}
  13.         {% set final_path_webp = source_path|imagine_filter('my_original_webp') %}
  14.     {% else %}
  15.         {% set original_path = asset('assets/shop/img/400x300.png') %}
  16.         {# {% set path = original_path %} #}
  17.         {% set final_path_webp = original_path %}
  18.         {% set final_path = original_path %}
  19.     {% endif %}
  20.     {% set taxon = product.mainTaxon %}
  21.     <div data-product-image="{{ final_path }}" data-product-link="{{ final_path }}"></div>
  22.         {# {{ dump(source_path|imagine_filter('my_thumb_webp')) }} #}
  23.     {% if taxon.slug == 'gift-cards' %}
  24.         <div class="ui fluid image">
  25.             <picture>
  26.                 {% if app.environment == "prod" %}
  27.                     <source id="picture_source_1" type="image/webp" data-original="{{ final_path_webp }}" srcset="{{ final_path_webp  }}">
  28.                     <source id="picture_source_2" type="image/jpeg" data-original="{{ final_path }}" srcset="{{ final_path   }}">
  29.                     <img width="200px" height="200px" style="width:100% !important; height: auto !important;" src="{{ final_path }}" id="main-image" alt="{{ product.name }}" {{ sylius_test_html_attribute('main-image') }} onerror="this.src='{{  final_path  }}';document.getElementById('picture_source_1').srcset=document.getElementById('picture_source_2').srcset=this.src;this.onerror=null;">
  30.                 {% else %}
  31.                     <source id="picture_source_1" type="image/webp" data-original="{{ final_path_webp }}" srcset="{{ final_path_webp }}">
  32.                     <source id="picture_source_2" type="image/jpeg" data-original="{{ final_path }}" srcset="{{ final_path }}">
  33.                     <img width="200px" height="200px" style="width:100% !important; height: auto !important;" src="{{ final_path }}" id="main-image" alt="{{ product.name }}" {{ sylius_test_html_attribute('main-image') }} onerror="this.src='{{ final_path }}';document.getElementById('picture_source_1').srcset=document.getElementById('picture_source_2').srcset=this.src;this.onerror=null;">
  34.                 {% endif %}
  35.                 {# <img src="{{ path }}" id="main-image" alt="{{ product.name }}" {{ sylius_test_html_attribute('main-image') }} /> #}
  36.             </picture>
  37.         </div>
  38.     {% else %}
  39.         <a href="{{ final_path }}" class="ui fluid image --" data-lightbox="sylius-product-image">
  40.             <picture>
  41.                 {# <source type="image/webp" data-original="{{ source_path }}" srcset="{{ source_path | imagine_filter(filter|default('sylius_shop_product_original')) ~ '.webp' | replace({"/resolve"}) }}"> #}
  42.                 {% if app.environment == "prod" %}
  43.                     <source id="picture_source_1" type="image/webp" data-original="{{ final_path_webp }}" srcset="{{ final_path_webp  }}">
  44.                     <source  id="picture_source_2" type="image/jpeg" data-original="{{ final_path }}" srcset="{{ final_path  }}">
  45.                     <img width="200px" height="200px" style="width:100% !important; height: auto !important;" src="{{ final_path  }}" id="main-image" alt="{{ product.name }}" {{ sylius_test_html_attribute('main-image') }} onerror="this.src='{{  final_path  }}';document.getElementById('picture_source_1').srcset=document.getElementById('picture_source_2').srcset=this.src;this.onerror=null;">
  46.                 {% else %}
  47.                     <source id="picture_source_1" type="image/webp" data-original="{{ final_path_webp }}" srcset="{{ final_path_webp }}">
  48.                     <source id="picture_source_2" type="image/jpeg" data-original="{{ final_path }}" srcset="{{ final_path }}">
  49.                     <img width="200px" height="200px" style="width:100% !important; height: auto !important;" src="{{ final_path }}" id="main-image" alt="{{ product.name }}" {{ sylius_test_html_attribute('main-image') }} onerror="this.src='{{ final_path }}';document.getElementById('picture_source_1').srcset=document.getElementById('picture_source_2').srcset=this.src;this.onerror=null;">
  50.                 {% endif %}
  51.             </picture>
  52.             {# <img src="{{ path }}" id="main-image" alt="{{ product.name }}" {{ sylius_test_html_attribute('main-image') }} /> #}
  53.         </a>
  54.     {% endif %}
  55.     {% if product.images|length > 1 %}
  56.     <div class="ui hidden divider"></div>
  57.     {{ sylius_template_event('sylius.shop.product.show.before_thumbnails', {'product': product}) }}
  58.     <div class="owl-carousel images">
  59.         {% for image in product.images %}
  60.             {% set path = image.path is not null ? image.path|imagine_filter('sylius_shop_product_small_thumbnail') : asset('assets/shop/img/200x200.png') %}
  61.             <div class="item">
  62.                 {% if product.isConfigurable() and product.enabledVariants|length > 0 %}
  63.                     {% include '@SyliusShop/Product/Show/_imageVariants.html.twig' %}
  64.                 {% endif %}
  65.                 <a href="{{ image.path|imagine_filter('sylius_shop_product_original') }}" data-lightbox="sylius-product-image">
  66.                     <img width="200px" height="200px" style="width:100% !important; height: auto !important;" src="{{ path }}" data-large-thumbnail="{{ image.path|imagine_filter('sylius_shop_product_large_thumbnail') }}" alt="{{ product.name }}" />
  67.                 </a>
  68.             </div>
  69.         {% endfor %}
  70.     </div>
  71.     {% endif %}
  72. </div>