custom/static-plugins/NdTheme/src/Resources/views/storefront/element/cms-element-image.html.twig line 1

Open in your IDE?
  1. {% block element_image %}
  2.     {% set config = element.fieldConfig.elements %}
  3.     <div class="cms-element-{{ element.type }}">
  4.         {% block element_product_slider_alignment %}
  5.             {% block element_image_inner %}
  6.                 {% set imageElement %}
  7.                     {% block element_image_container %}
  8.                         {% if element.data.media.url %}
  9.                             {% if element.config.imageRatio.value == 'aspect-square' %}
  10.                                 {% set image_ratio =  'ratio_1x1' %}
  11.                             {% elseif element.config.imageRatio.value == 'aspect-video' %}
  12.                                 {% set image_ratio =  'ratio_16x9' %}
  13.                             {% else %}
  14.                                 {% set image_ratio =  'ratio_3x4' %}
  15.                             {% endif %}
  16.                             <div class="cms-image-container ratio {{ image_ratio }}">
  17.                                 {% block element_image_media %}
  18.                                     {% set attributes = {
  19.                                         'alt': (element.data.media.translated.alt ?: ''),
  20.                                         'title': (element.data.media.translated.title ?: '')
  21.                                     } %}
  22.                                     {% if element.translated.config.displayMode.value == 'cover' or element.translated.config.displayMode.value == 'contain' %}
  23.                                         {% set attributes = attributes|merge({ 'data-object-fit': element.translated.config.displayMode.value }) %}
  24.                                     {% endif %}
  25.                                     {% sw_thumbnails 'cms-image-thumbnails' with {
  26.                                         media: element.data.media
  27.                                     } %}
  28.                                 {% endblock %}
  29.                             </div>
  30.                         {% endif %}
  31.                     {% endblock %}
  32.                 {% endset %}
  33.                 {% if element.translated.config.url.value %}
  34.                     <a href="{{ element.translated.config.url.value }}"
  35.                        class="cms-image-link"
  36.                        {% if element.translated.config.newTab.value %}target="_blank" rel="noopener"{% endif %}>
  37.                         {{ imageElement }}
  38.                     </a>
  39.                 {% else %}
  40.                     {{ imageElement }}
  41.                 {% endif %}
  42.             {% endblock %}
  43.             {% if config.verticalAlign.value %}
  44.                 </div>
  45.             {% endif %}
  46.         {% endblock %}
  47.     </div>
  48. {% endblock %}