templates/_elements/image.html.twig line 1

Open in your IDE?
  1. {% set lazy = lazy|default(false) %}
  2. {% set placeholder = placeholder|default(false) %}
  3. {% set mode = mode|default('basic') %}
  4. {% set class = class|default('') %}
  5. {% set alt = alt|default('') %}
  6. {% set width = width|default('') %}
  7. {% set height = height|default('') %}
  8. {% if width == false %}
  9. {% set imagesize = imagesize(src) %}
  10. {% set width = imagesize[0] %}
  11. {% set height = imagesize[1] %}
  12. {% endif %}
  13. <div class="image{% if lazy %} image--lazy{% endif %}{% if placeholder %} image--placeholder{% endif %}{% if mode %} image--{{mode}}{% endif %} {{class}}">
  14. {% if lazy %}
  15. <img class="image__img js-lazy" src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 {{width}} {{height}}'%3E%3C/svg%3E" data-src="{{src}}" alt="{{alt}}" width="{{width}}" height="{{height}}" data-size="{{width}}x{{height}}" draggable="false">
  16. {% else %}
  17. <img class="image__img" src="{{src}}" alt="{{alt}}" width="{{width}}" height="{{height}}" data-size="{{width}}x{{height}}" draggable="false">
  18. {% endif %}
  19. </div>