{% if product.imagesByType('main') is not empty %}
{% set path = product.imagesByType('main').first.path|imagine_filter(filter|default('sylius_shop_product_small_thumbnail')) %}
{% set alt = product.imagesByType('main').first.alt %}
{% if app_file_exists((path ~ ".webp")|replace({"resolve/": ""})) %}
<picture>
<source srcset="{{ (path ~ ".webp")|replace({'resolve/':''}) }}" {% if class is defined %}class="{{ class }}"{% endif %} {{ sylius_test_html_attribute('main-image') }} />
<img src="{{ (path) }}" alt="{{ alt }}" {% if class is defined %}class="{{ class }}"{% endif %} {{ sylius_test_html_attribute('main-image') }} />
</picture>
{% else %}
<img src="{{ (path) }}" alt="{{ alt }}"class="w-100"{{ sylius_test_html_attribute('main-image') }} />
{% endif %}
{% elseif product.images.first %}
{% set path = product.images.first.path|imagine_filter(filter|default('sylius_shop_product_small_thumbnail')) %}
{% set alt = product.images.first.alt %}
{% if app_file_exists((path ~ ".webp")|replace({"resolve/": ""})) %}
<picture>
<source srcset="{{ (path ~ ".webp")|replace({'resolve/':''}) }}" {% if class is defined %}class="{{ class }}"{% endif %} {{ sylius_test_html_attribute('main-image') }} />
<img src="{{ (path) }}" alt="{{ alt }}" {% if class is defined %}class="{{ class }}"{% endif %} {{ sylius_test_html_attribute('main-image') }} />
</picture>
{% else %}
<img src="{{ (path) }}" alt="{{ alt }}"class="w-100"{{ sylius_test_html_attribute('main-image') }} />
{% endif %}
{% else %}
{% set alt = product.name %}
{% endif %}
{% if alt == "" or alt is null %}
{% set alt = product.name %}
{% endif %}