templates/default/components/atoms/image/image.html.twig line 1

Open in your IDE?
  1. {# Make the component not only compatible with Storyblok "Image (old)" type but also with the newer "Asset" type: #}
  2. {% if src is defined and src.filename is defined %}
  3. {% set asset = src %}
  4. {% set srcFocus = src.focus %}
  5. {% set src = src.filename %}
  6. {% endif %}
  7. {% if static|default(null) or not ('//' in src|default) %}
  8. <picture class="image">
  9. <img src="{{ src|default }}" alt="{{ alt|default(asset.alt|default) }}" class="image__src {{ class|default }}" {{ attributes|default([])|getAttributes }}>
  10. </picture>
  11. {% else %}
  12. <image-wrapper
  13. base-url="{{ imageservice }}"
  14. src-url="{{ src|default }}"
  15. css-class="{{ class|default }}"
  16. alt="{{ alt|default }}"
  17. attributes="{{ attributes|default([])|json_encode }}"
  18. {% if lazyload is defined and lazyload == false %} no-lazy-load{% endif %}
  19. {% if resize is defined and resize == false %} no-resize{% endif %}
  20. object-fit="{{ objectFit|default('width') }}"
  21. focus="{{ srcFocus|default }}"
  22. :width="{{ width|default('null') }}"
  23. :height="{{ height|default('null') }}"
  24. >
  25. </image-wrapper>
  26. {% if imageSimilar|default(false) %}
  27. <span class="imagesimilar">
  28. {{ "product_image_similar"|trans }}
  29. </span>
  30. {% endif %}
  31. <noscript>
  32. <picture>
  33. <img src="{{ src|default }}" alt="{{ alt|default }}" class="image__src {{ class|default }}">
  34. </picture>
  35. </noscript>
  36. {% endif %}