themes/BootstrapChildTheme/SyliusShopBundle/views/Product/_mainImage.html.twig line 1

Open in your IDE?
  1. {% if product.imagesByType('thumbnail') is not empty %}
  2.     {% set originalPath = product.imagesByType('thumbnail').first.path %}
  3.     {% set path = product.imagesByType('thumbnail').first.path|imagine_filter(filter|default('sylius_shop_product_thumbnail')) %}
  4.     {% set final_path_webp = originalPath|imagine_filter('my_thumb_webp') %}
  5. {% elseif product.images.first %}
  6.     {% set originalPath = product.images.first.path %}
  7.     {% set path = product.images.first.path|imagine_filter(filter|default('sylius_shop_product_thumbnail')) %}
  8.     {% set final_path_webp = originalPath|imagine_filter('my_thumb_webp') %}
  9. {% else %}
  10.     {% set originalPath = asset('assets/shop/img/placeholder_max.jpg') %}
  11.     {% set path = asset('assets/shop/img/placeholder_max.jpg') %}
  12.     {% set final_path_webp = originalPath %}
  13. {% endif %}
  14. {% set bordered = bordered ?? true %}
  15. <picture>
  16. {% if app.environment == "prod" %}
  17.     <source id="{{product.id}}_pic_src_1" srcset="{{ final_path_webp  }}" type="image/webp">
  18.     <source id="{{product.id}}_pic_src_2" srcset="{{ path  }}" type="image/jpeg">
  19.     <img width="200px" height="200px" style="width:100% !important; height: auto !important;" src="{{ path  }}" alt="{{ product.name }}" class="ui {% if bordered %}bordered{% endif %} image" onerror="this.src='{{  path  }}';document.getElementById('{{product.id}}_pic_src_1').srcset=document.getElementById('{{product.id}}_pic_src_2').srcset=this.src;this.onerror=null;">
  20. {% else %}
  21.     <source id="{{product.id}}_pic_src_1" srcset="{{ final_path_webp }}" type="image/webp">
  22.     <source id="{{product.id}}_pic_src_2" srcset="{{ path }}" type="image/jpeg">
  23.     <img width="200px" height="200px" style="width:100% !important; height: auto !important;" src="{{ path }}" alt="{{ product.name }}" class="ui {% if bordered %}bordered{% endif %} image" onerror="this.src='{{path}}';document.getElementById('{{product.id}}_pic_src_1').srcset=document.getElementById('{{product.id}}_pic_src_2').srcset=this.src;this.onerror=null;">
  24. {% endif %}
  25. {# <img src="{{ path }}" {{ sylius_test_html_attribute('main-image') }} alt="{{ product.name }}" class="ui bordered image" /> #}
  26. </picture>