stack/src/components/items/media-item/media-item.twig line 1

Open in your IDE?
  1. {% set is_video = props.video.src ? true : false %}
  2. {% set is_product = props.variant == "product" ? true : false %}
  3. {%- set class_name = [
  4.   "i-media",
  5.   "u-posr",
  6.   is_video ? "--video u-img-hover" : null,
  7.   is_product ? "--product" : null
  8. ]|join(' ')|trim -%}
  9. {%- set attrs = [
  10.   'class="' ~ class_name ~ '"',
  11. ] -%}
  12. {%- if is_video %}
  13.   {%- set attrs = attrs|merge(['data-fancybox data-src="' ~ props.video.src ~ '"']) -%}
  14. {%- endif -%}
  15. {%- set attrs = attrs|join(' ')|trim -%}
  16. {% set img_props = {
  17.   width: is_product ? 656 : 568,
  18.   height: is_product ? 656 : 568,
  19.   objectfit: is_product ? "contain" : "cover",
  20.   is_placeholder: true,
  21.   ratio: "1-1",
  22. } %}
  23. <div {{ attrs|raw }}>
  24.   {% if props.img %}
  25.     {% include "@Components/img/img.twig" with {props: props.img|merge(img_props)} %}
  26.   {% else %}
  27.     {% include "@Components/img/img.twig" with {props: {
  28.       src: base_path ~ "images/content/placeholder.png",
  29.     }|merge(img_props)} %}
  30.   {% endif %}
  31.   {% if is_video %}
  32.     <div class="i-media__play-icon u-posa u-top-50-p u-left-50-p u-translate-middle">
  33.       {% include "@Components/icon/icon.twig" with {props: {
  34.         src: "@Images/svg/play.svg",
  35.         size: "xxl",
  36.         color: "primary",
  37.       }} %}
  38.     </div>
  39.   {% endif %}
  40.   {% if props.tag and is_product %}
  41.     {% include "@Components/items/tag-item/tag-item.twig" with {props: {
  42.       title: props.tag.title,
  43.       size: "sm-base",
  44.       variant: "product",
  45.       extra_class: "i-media__tag u-posa"
  46.     }} %}
  47.   {% endif %}
  48. </div>