stack/src/components/items/gallery-slide-item/gallery-slide-item.twig line 1

Open in your IDE?
  1. {%- set class_name = [
  2.   "i-gallery-slide",
  3.   "u-posr",
  4. ]|join(' ')|trim -%}
  5. {%- set attrs = [
  6.   'class="' ~ class_name ~ '"',
  7. ] -%}
  8. {%- set attrs = attrs|join(' ')|trim -%}
  9. {% if props.size == "large" %}
  10.   {%- set tag = "button" -%}
  11. {% else %}
  12.   {%- set tag =  "a" -%}
  13. {% endif %}
  14. {% set img = props.size == "large" ? props.large_img : props.img %}
  15. {%- set item_class_name = [
  16.   "i-gallery-slide__link",
  17.   "d-block",
  18. ]|join(' ')|trim -%}
  19. {%- set item_attrs = [
  20.   'class="' ~ item_class_name ~ '"',
  21. ] -%}
  22. {%- if tag == "button" %}
  23.   {%- set item_attrs = item_attrs|merge(['type="button"']) -%}
  24. {%- endif -%}
  25. {%- if tag == "a" %}
  26.   {%- set item_attrs = item_attrs|merge(['data-fancybox="' ~ props.img.data_fancybox ~ '"']) -%}
  27. {%- endif -%}
  28. {% if tag == "a" and props.img.href %}
  29.   {%- set item_attrs = item_attrs|merge(['href="' ~ props.img.href ~ '"']) -%}
  30. {% endif %}
  31. {% if tag == "a" and not props.img.href %}
  32.   {%- set item_attrs = item_attrs|merge(['href="' ~ base_path ~ "images/content/placeholder.png" ~ '"']) -%}
  33. {% endif %}
  34. {%- set item_attrs = item_attrs|join(' ')|trim -%}
  35. {% set img_props = {
  36.   objectfit: "contain",
  37.   alt: props.img.alt|default(props.title),
  38.   is_placeholder: false,
  39.   ratio:"1-1",
  40.   native_lazyload: true,
  41. } %}
  42. <div {{ attrs|raw }}>
  43.   <div class="i-gallery-slide__image">
  44.     <{{tag}} {{ item_attrs|raw }}>
  45.       {% if img %}
  46.         {% include "@Components/img/img.twig" with {props: img|merge(img_props)} %}
  47.       {% else %}
  48.         {% include "@Components/img/img.twig" with {props: img_props|merge({
  49.           src: base_path ~ "images/content/placeholder.png",
  50.         })} %}
  51.       {% endif %}
  52.     </{{tag}}>
  53.     {% if props.tag and props.size == "large" %}
  54.       {% include "@Components/items/tag-item/tag-item.twig" with {props: {
  55.         title: props.tag.title,
  56.         size: "sm-base",
  57.         variant: "product",
  58.         extra_class: "i-gallery-slide__tag u-posa"
  59.       }} %}
  60.     {% endif %}
  61.   </div>
  62. </div>