custom/plugins/NenoHeroSlider/src/Resources/views/storefront/base.html.twig line 1

Open in your IDE?
  1. {% sw_extends '@Storefront/storefront/base.html.twig' %}
  2. {% block base_main %}
  3.     {% block neno_hero_slider %}
  4.     {% if page.extensions.hero_slider_slides %}
  5.         {% set slides = page.extensions.hero_slider_slides.elements %}
  6.         {% if slides|length > 0 %}
  7.         {% set config = config('NenoHeroSlider.config') %}
  8.         {% set validMediaIds = [
  9.             config.leftArrowIconGraphic,
  10.             config.rightArrowIconGraphic,
  11.             config.scrollIndicatorIconGraphic,
  12.         ]|filter(id => id is not null) %}
  13.         {% set customMediaCollection = searchMedia(validMediaIds, context.context) %}
  14.         {% set customLeftArrowGraphic = customMediaCollection.get(config.leftArrowIconGraphic) %}
  15.         {% set customRightArrowGraphic = customMediaCollection.get(config.rightArrowIconGraphic) %}
  16.         {% set customScrollIndicatorGraphic = customMediaCollection.get(config.scrollIndicatorIconGraphic) %}
  17.         {% set controlsDisabled = config.oneSlideControlsDisabled ? (slides|length < 2) : false %}
  18.         {% set aspectRatioLandscape = (
  19.             config.aspectRatioWidth and config.aspectRatioHeight and config.aspectRatioHeight is not same as(0)
  20.                 ? (config.aspectRatioWidth / config.aspectRatioHeight)
  21.                 : 2
  22.         ) %}
  23.         {% set aspectRatioPortrait = (
  24.             config.inheritAspectRatioForPortrait
  25.                 ? aspectRatioLandscape
  26.                 : (
  27.                     config.aspectRatioWidthPortrait and config.aspectRatioHeightPortrait and config.aspectRatioHeightPortrait is not same as(0)
  28.                         ? (config.aspectRatioWidthPortrait / config.aspectRatioHeightPortrait)
  29.                         : 0.6
  30.                 )
  31.         ) %}
  32.         {% set heroSliderUserConfig = {
  33.             heightScaleMode: config.heightScaleMode,
  34.             heightScaleModePortrait: config.heightScaleModePortrait is same as('inherit') ? config.heightScaleMode : config.heightScaleModePortrait,
  35.             forceLoadPortraitWhenDeviceIsPortrait: config.forceLoadPortraitImagesOnPortraitDevices ? true : false,
  36.             forceLoadLandscapeWhenDeviceIsLandscape: config.forceLoadLandscapeImagesOnLandscapeDevices ? true : false,
  37.             transitionMode: config.transitionMode ?: 'slide',
  38.             aspectRatio: aspectRatioLandscape,
  39.             aspectRatioPortrait: aspectRatioPortrait,
  40.             useInterval: config.useInterval and not controlsDisabled ? true : false,
  41.             boundaryMode: config.boundaryMode ?: 'infinite',
  42.             infiniteWrapMode: config.infiniteWrapMode ?: 'loop',
  43.             transitionDuration: config.transitionDuration ?: 1,
  44.             transitionEasingCurve: config.easingCurve ?: 'EASE',
  45.             interval: config.intervalDuration ? (config.intervalDuration * 1000) : 12000,
  46.             fadeScrollIndicatorOnScroll: config.animateScrollIndicator ? true : false,
  47.             scrollOnScrollIndicatorClick: config.scrollOnScrollIndicatorClick ? true : false,
  48.             enableArrowKeyControl: config.enableArrowKeyControl and not controlsDisabled ? true : false,
  49.             touchDragEnabled: config.enableTouchSwiping ? true : false,
  50.             mouseDragEnabled: config.enableMouseSwiping ? true : false,
  51.         } %}
  52.         <div
  53.             class="hero-slider{% if config.transitionMode is same as('slide') %} hero-slider-mode-slide{% else %} hero-slider-mode-blend{% endif %}"
  54.             id="hero-slider"
  55.             data-hero-slider
  56.             data-hero-slider-options='{{ heroSliderUserConfig|json_encode }}'
  57.         >
  58.             <noscript>
  59.                 <style>
  60.                     .hero-slider {
  61.                         overflow: auto; !important;
  62.                     }
  63.                     .hero-slider,
  64.                     .hero-slider-slide-container {
  65.                         height: 60vh !important;
  66.                     }
  67.                     .hero-slider-image {
  68.                         width: 100% !important;
  69.                         height: auto !important;
  70.                     }
  71.                     .hero-slider {
  72.                         position: relative !important;
  73.                     }
  74.                     .hero-slider-image {
  75.                         position: static !important;
  76.                     }
  77.                     .hero-slider-scroll-overlay,
  78.                     .hero-slider-navigation-btn,
  79.                     .hero-slider-menu {
  80.                         display: none;
  81.                     }
  82.                 </style>
  83.             </noscript>
  84.             <div class="hero-slider-slide-container">
  85.                 {% apply spaceless %}
  86.                 {% for slide in slides %}
  87.                 {% if slide.mediaLandscape %}
  88.                     {% set alt_title_landscape = slide.translated.imageAltTitle ?: slide.mediaLandscape.alt %}
  89.                     {% set landscape_thumbnails = slide.mediaLandscape.thumbnails|sort|reverse|json_encode %}
  90.                 {% endif %}
  91.                 {% if slide.mediaPortrait %}
  92.                     {% set alt_title_portrait = slide.translated.imageAltTitle ?: slide.mediaLandscape.alt %}
  93.                     {% set portrait_thumbnails = slide.mediaPortrait.thumbnails|sort|reverse|json_encode %}
  94.                 {% endif %}
  95.                 <div
  96.                     class="hero-slider-slide{% if slide.cssClass %} {{ slide.cssClass|sw_sanitize }}{% endif %}"
  97.                     data-animation-duration="60"
  98.                     data-animation-preset-landscape="{{ slide.imageMovementPresetLandscape ?: 'NONE' }}"
  99.                     data-animation-preset-portrait="{{ slide.imageMovementPresetPortrait ?: 'NONE' }}"
  100.                     style="background-color: {{ slide.backgroundColor ?: 'transparent' }}"
  101.                 >
  102.                     {% if slide.mediaLandscape or slide.mediaPortrait %}
  103.                     <img
  104.                         class="hero-slider-image"
  105.                         alt="{{ slide.translated.imageAltTitle ?: (slide.mediaLandscape.alt ?: slide.mediaPortrait.alt) }}"
  106.                         {% apply spaceless %}
  107.                         {% if slide.mediaPortrait %}
  108.                         {% block neno_hero_slider_slide_portrait_srcset %}
  109.                             {% if slide.mediaPortrait.thumbnails|length > 0 %}
  110.                             {% set thumbnails = slide.mediaPortrait.thumbnails|sort|reverse %}
  111.                             {# generate srcset with all available thumbnails #}
  112.                             {% set srcsetValue %}{% apply spaceless %}
  113.                                 {{ slide.mediaPortrait|sw_encode_media_url }} {{ thumbnails|first.width + 1 }}w, {% for thumbnail in thumbnails %}{{ thumbnail.url | sw_encode_url }} {{ thumbnail.width }}w{% if not loop.last %}, {% endif %}{% endfor %}
  114.                             {% endapply %}{% endset %}
  115.                             data-srcset-portrait="{{ srcsetValue }}"
  116.                             {% endif %}
  117.                             data-src-portrait="{{ slide.mediaPortrait|sw_encode_media_url }}"
  118.                         {% endblock %}
  119.                         {% endif %}
  120.                         {% if slide.mediaLandscape %}
  121.                         {% block neno_hero_slider_slide_landscape_srcset %}
  122.                             {% if slide.mediaLandscape.thumbnails|length > 0 %}
  123.                             {% set thumbnails = slide.mediaLandscape.thumbnails|sort|reverse %}
  124.                             {# generate srcset with all available thumbnails #}
  125.                             {% set srcsetValue %}{% apply spaceless %}
  126.                                 {{ slide.mediaLandscape|sw_encode_media_url }} {{ thumbnails|first.width + 1 }}w, {% for thumbnail in thumbnails %}{{ thumbnail.url | sw_encode_url }} {{ thumbnail.width }}w{% if not loop.last %}, {% endif %}{% endfor %}
  127.                             {% endapply %}{% endset %}
  128.                             data-srcset-landscape="{{ srcsetValue }}"
  129.                             {% endif %}
  130.                             data-src-landscape="{{ slide.mediaLandscape|sw_encode_media_url }}"
  131.                         {% endblock %}
  132.                         {% endif %}
  133.                         {% endapply %}
  134.                         sizes="100vw"
  135.                     >
  136.                         <noscript>
  137.                             {% if slide.mediaLandscape %}
  138.                             {% sw_thumbnails 'hero-slider-thumbnails-landscape' with {
  139.                                 media: slide.mediaLandscape,
  140.                                 attributes: {
  141.                                     alt: alt_title_landscape,
  142.                                     class: 'hero-slider-thumbnails hero-slider-thumbnails-landscape'
  143.                                 }
  144.                             } %}
  145.                             {% endif %}
  146.                             {% if slide.mediaPortrait %}
  147.                             {% sw_thumbnails 'hero-slider-thumbnails-portrait' with {
  148.                                 media: slide.mediaPortrait,
  149.                                 attributes: {
  150.                                     alt: alt_title_portrait,
  151.                                     class: 'hero-slider-thumbnails hero-slider-thumbnails-portrait'
  152.                                 }
  153.                             } %}
  154.                             {% endif %}
  155.                         </noscript>
  156.                     </img>
  157.                     {% endif %}
  158.                     <div class="hero-slider-overlay" role="presentation" style="background-color: {{ slide.overlayColor ?: (config.defaultOverlayColor ?: 'transparent') }}"></div>
  159.                     {% if slide.translated.slideLink %}
  160.                     <a class="hero-slider-slide-link" href="{{ slide.translated.slideLink }}" title="{{ slide.translated.buttonLinkText ?: ('neno-hero-slider.openLink'|trans) }}" {% if slide.translated.slideLinkNewTab %} target="_blank" rel="noopener"{% endif %} draggable="false"></a>
  161.                     {% endif %}
  162.                     <div class="hero-slider-content-container hs-vertical-align-{{ config.verticalTextBlockAlignment ?: 'center' }} hs-horizontal-align-{{ config.horizontalTextBlockAlignment ?: 'left' }}">
  163.                         {% if slide.translated.textContentBeforeHeadline or slide.translated.headline or slide.translated.textContentAfterHeadline or slide.translated.buttonLink %}
  164.                         <div class="hero-slider-description hs-t-align-{{ config.defaultTextAlignment ?: 'left' }}" style="background-color: {{ config.textBlockBackgroundColor ?: 'transparent' }}; color: {{ config.defaultTextBlockColor ?: 'white' }}">
  165.                             <div class="hero-slider-content-before">{{ ((slide.translated.textContentBeforeHeadline|raw) ?: '')|sw_sanitize }}</div>
  166.                             {% set headline_tag_name = (loop.first ? (config.headlineTagNameFirstSlide ?: 'h2') : ((config.headlineTagNameFollowingSlides ?: 'h2'))) %}
  167.                             <{{ headline_tag_name }} class="hero-slider-headline">{{ ((slide.translated.headline|raw) ?: '')|sw_sanitize }}</{{ headline_tag_name }}>
  168.                             <div class="hero-slider-content-after">{{ ((slide.translated.textContentAfterHeadline|raw) ?: '')|sw_sanitize }}</div>
  169.                             {% if slide.translated.buttonLink %}
  170.                             <div class="hero-slider-cta-container hs-t-align-{{ config.ctaButtonAlignment ?: 'left' }}">
  171.                                 <a class="btn btn-{{ config.ctaButtonType ?: 'primary' }} hero-slider-cta-btn" title="{{ slide.translated.buttonLinkText }}" tabindex="-1" href="{{ slide.translated.buttonLink }}"{% if slide.translated.buttonLinkNewTab %} target="_blank" rel="noopener"{% endif %}>
  172.                                     {{ slide.translated.buttonLinkText }}
  173.                                 </a>
  174.                             </div>
  175.                             {% endif %}
  176.                         </div>
  177.                         {% endif %}
  178.                     </div>
  179.                 </div>
  180.                 {% endfor %}
  181.                 {% endapply %}
  182.             </div>
  183.             {% if config.showNavigationControls and not controlsDisabled %}
  184.             <button
  185.                 type="button"
  186.                 class="hero-slider-btn hero-slider-navigation-btn hero-slider-navigation-btn-left"
  187.                 aria-controls="hero-slider"
  188.                 aria-label="{{ 'neno-hero-slider.controls.prevTitle' | trans }}"
  189.                 title="{{ 'neno-hero-slider.controls.prevTitle' | trans }}"
  190.             >
  191.                 {% block neno_hero_slider_prev_icon %}
  192.                     {% if customLeftArrowGraphic %}
  193.                         <span
  194.                             class="icon hs-custom-icon"
  195.                             style="background-image: url('{{ customLeftArrowGraphic.url }}');"
  196.                             role="presentation"
  197.                         ></span>
  198.                     {% else %}
  199.                         {% sw_icon 'arrow-head-left' %}
  200.                     {% endif %}
  201.                 {% endblock %}
  202.             </button>
  203.             <button
  204.                 type="button"
  205.                 class="hero-slider-btn hero-slider-navigation-btn hero-slider-navigation-btn-right"
  206.                 aria-controls="hero-slider"
  207.                 aria-label="{{ 'neno-hero-slider.controls.nextTitle' | trans }}"
  208.                 title="{{ 'neno-hero-slider.controls.nextTitle' | trans }}"
  209.             >
  210.                 {% block neno_hero_slider_next_icon %}
  211.                     {% if customRightArrowGraphic %}
  212.                         <span
  213.                             class="icon hs-custom-icon"
  214.                             style="background-image: url('{{ customRightArrowGraphic.url }}');"
  215.                             role="presentation"
  216.                         ></span>
  217.                     {% else %}
  218.                         {% sw_icon 'arrow-head-right' %}
  219.                     {% endif %}
  220.                 {% endblock %}
  221.             </button>
  222.             {% endif %}
  223.             {% if config.showJumpNavigation and not controlsDisabled %}
  224.             <div class="hero-slider-menu hs-{{ config.bulletDirection ?: 'vertical' }}" role="menu">
  225.                 {% for slide in slides %}
  226.                 <button type="button" class="hero-slider-btn hero-slider-menu-item" role="menuitemradio"></button>
  227.                 {% endfor %}
  228.             </div>
  229.             {% endif %}
  230.             {% if config.showScrollIndicator %}
  231.                 <div class="hero-slider-scroll-overlay hs-horizontal-align-{{ config.scrollIndicatorAlignment ?: 'center' }}" role="presentation">
  232.                     <button type="button" title="{{ 'neno-hero-slider.scrollDown'|trans }}" class="hero-slider-btn hero-slider-scroll-icon hs-interactive">
  233.                         {% if customScrollIndicatorGraphic %}
  234.                             <span
  235.                                 class="icon hs-custom-icon"
  236.                                 style="background-image: url('{{ customScrollIndicatorGraphic.url }}');"
  237.                                 role="presentation"
  238.                             ></span>
  239.                         {% else %}
  240.                             {% sw_icon 'arrow-head-down' %}
  241.                         {% endif %}
  242.                     </button>
  243.                 </div>
  244.             {% endif %}
  245.         </div>
  246.         {% block neno_hero_slider_user_style %}
  247.             <style>
  248.                 .hero-slider .hero-slider-navigation-btn {
  249.                 {% if config.navigationControlBackgroundColor %}
  250.                     background-color: {{ config.navigationControlBackgroundColor }};
  251.                 {% endif %}
  252.                 {% if config.navigationControlIconColor %}
  253.                     color: {{ config.navigationControlIconColor }};
  254.                 {% endif %}
  255.                 }
  256.                 .hero-slider .hero-slider-scroll-icon {
  257.                 {% if config.navigationControlBackgroundColor %}
  258.                     background-color: {{ config.scrollIndicatorBackgroundColor }};
  259.                 {% endif %}
  260.                 {% if config.navigationControlIconColor %}
  261.                     color: {{ config.scrollIndicatorIconColor }};
  262.                 {% endif %}
  263.                 }
  264.                 .hero-slider .hero-slider-menu-item {
  265.                 {% if config.jumpNavigationItemBackgroundColor %}
  266.                     background-color: {{ config.jumpNavigationItemBackgroundColor }};
  267.                 {% endif %}
  268.                 {% if config.jumpNavigationItemBorderColor %}
  269.                     border-color: {{ config.jumpNavigationItemBorderColor }};
  270.                 {% endif %}
  271.                 }
  272.                 .hero-slider .hero-slider-menu-item:after,
  273.                 .hero-slider .hero-slider-menu-item::after {
  274.                 {% if config.jumpNavigationItemFillColor %}
  275.                     background-color: {{ config.jumpNavigationItemFillColor }};
  276.                 {% endif %}
  277.                 }
  278.                 .hero-slider .btn.hero-slider-cta-btn {
  279.                 {% if config.ctaButtonType is same as('primary') %}
  280.                 {% if config.ctaButtonBackgroundColor %}
  281.                     background-color: {{ config.ctaButtonBackgroundColor }};
  282.                 {% endif %}
  283.                 {% if config.ctaButtonBackgroundColor %}
  284.                     border-color: {{ config.ctaButtonBackgroundColor }};
  285.                 {% endif %}
  286.                 {% if config.ctaButtonBackgroundColor %}
  287.                     color: {{ config.ctaButtonTextColor }};
  288.                 {% endif %}
  289.                 {% else %}
  290.                 {% if config.ctaButtonBackgroundColor %}
  291.                     border-color: {{ config.ctaButtonBackgroundColor }};
  292.                 {% endif %}
  293.                 {% if config.ctaButtonBackgroundColor %}
  294.                     color: {{ config.ctaButtonBackgroundColor }};
  295.                 {% endif %}
  296.                 {% endif %}
  297.                     font-family: {{ config.buttonFontFamily ? ('"' ~ config.buttonFontFamily ~ '"')|raw|sw_sanitize : 'inherit' }};
  298.                     font-size: {{ config.buttonFontSize ? (config.buttonFontSize ~ 'rem') : '.875rem' }};
  299.                     margin-bottom: {{ config.belowButtonGap ? (config.belowButtonGap ~ 'em') : '0' }};
  300.                 }
  301.                 .hero-slider .btn.hero-slider-cta-btn:hover {
  302.                 {% if config.ctaButtonType is same as('primary') %}
  303.                 {% if config.ctaButtonBackgroundColor %}
  304.                     background-color: {{ config.ctaButtonHoverBackgroundColor ?: config.ctaButtonBackgroundColor }};
  305.                 {% endif %}
  306.                 {% if config.ctaButtonBackgroundColor %}
  307.                     border-color: {{ config.ctaButtonBackgroundColor }};
  308.                 {% endif %}
  309.                 {% if config.ctaButtonTextColor %}
  310.                     color: {{ config.ctaButtonTextColor }};
  311.                 {% endif %}
  312.                 {% else %}
  313.                 {% if config.ctaButtonBackgroundColor %}
  314.                     border-color: {{ config.ctaButtonBackgroundColor }};
  315.                 {% endif %}
  316.                 {% if config.ctaButtonBackgroundColor %}
  317.                     background-color: {{ config.ctaButtonBackgroundColor }};
  318.                 {% endif %}
  319.                 {% if config.ctaButtonBackgroundColor %}
  320.                     color: {{ config.ctaButtonTextColor }};
  321.                 {% endif %}
  322.                 {% endif %}
  323.                 }
  324.                 .hero-slider .hero-slider-headline {
  325.                     color: {{ config.headlineColor ?: (config.defaultTextBlockColor ?: 'inherit') }};
  326.                     font-family: {{ config.headlineFontFamily ? ('"' ~ config.headlineFontFamily ~ '"')|raw|sw_sanitize : 'inherit' }};
  327.                     font-weight: {{ config.headlineFontWeight ?: 'bold' }};
  328.                     font-size: {{ config.headlineFontSizeXs ? (config.headlineFontSizeXs ~ 'rem') : 'initial' }};
  329.                     line-height: {{ config.headlineLineHeight ?: 'inherit' }};
  330.                     margin-bottom: {{ config.afterHeadlineGap ? (config.afterHeadlineGap ~ 'em') : '0' }};
  331.                 }
  332.                 .hero-slider .hero-slider-content-before {
  333.                     font-family: {{ config.textAboveHeadlineFontFamily ? ('"' ~ config.textAboveHeadlineFontFamily ~ '"')|raw|sw_sanitize : 'inherit' }};
  334.                     font-size: {{ config.fontSizeAboveHeadlineXs ? (config.fontSizeAboveHeadlineXs ~ 'rem') : 'initial' }};
  335.                     line-height: {{ config.textAboveHeadlineLineHeight ?: 'inherit' }};
  336.                     margin-bottom: {{ config.beforeHeadlineGap ? (config.beforeHeadlineGap ~ 'em') : '0' }};
  337.                 }
  338.                 .hero-slider .hero-slider-content-after {
  339.                     font-family: {{ config.textBelowHeadlineFontFamily ? ('"' ~ config.textBelowHeadlineFontFamily ~ '"')|raw|sw_sanitize : 'inherit' }};
  340.                     font-size: {{ config.fontSizeBelowHeadlineXs ? (config.fontSizeBelowHeadlineXs ~ 'rem') : 'initial' }};
  341.                     line-height: {{ config.textBelowHeadlineLineHeight ?: 'inherit' }};
  342.                     margin-bottom: {{ config.afterTextBelowHeadlineGap ? (config.afterTextBelowHeadlineGap ~ 'em') : '0' }};
  343.                 }
  344.                 {% if config.textTransitionMode is same as('fadein') %}
  345.                 .hero-slider .hero-slider-slide .hero-slider-description {
  346.                     opacity: 0;
  347.                     transition: opacity .7s ease, transform .5s ease;
  348.                     transition-delay: {{ config.transitionDuration ?: 0 }}s;
  349.                     transform: translateY(10%);
  350.                 }
  351.                 .hero-slider .hero-slider-slide.active .hero-slider-description {
  352.                     opacity: 1;
  353.                     transform: translateY(0);
  354.                 }
  355.                 {% endif %}
  356.                 @media all and (min-width: {{ (theme_config('breakpoint.md') - 1) ~ 'px' }}) {
  357.                     .hero-slider .hero-slider-headline {
  358.                         font-size: {{ config.headlineFontSizeMd ? (config.headlineFontSizeMd ~ 'rem') : 'initial' }};
  359.                     }
  360.                     .hero-slider .hero-slider-content-before {
  361.                         font-size: {{ config.fontSizeAboveHeadlineMd ? (config.fontSizeAboveHeadlineMd ~ 'rem') : 'initial' }};
  362.                     }
  363.                     .hero-slider .hero-slider-content-after {
  364.                         font-size: {{ config.fontSizeBelowHeadlineMd ? (config.fontSizeBelowHeadlineMd ~ 'rem') : 'initial' }};
  365.                     }
  366.                 }
  367.                 @media all and (min-width: {{ (theme_config('breakpoint.lg') - 1) ~ 'px' }}) {
  368.                     .hero-slider .hero-slider-headline {
  369.                         font-size: {{ config.headlineFontSizeLg ? (config.headlineFontSizeLg ~ 'rem') : 'initial' }};
  370.                     }
  371.                     .hero-slider .hero-slider-content-before {
  372.                         font-size: {{ config.fontSizeAboveHeadlineLg ? (config.fontSizeAboveHeadlineLg ~ 'rem') : 'initial' }};
  373.                     }
  374.                     .hero-slider .hero-slider-content-after {
  375.                         font-size: {{ config.fontSizeBelowHeadlineLg ? (config.fontSizeBelowHeadlineLg ~ 'rem') : 'initial' }};
  376.                     }
  377.                 }
  378.                 {{ config.userInjectedCSS ? (config.userInjectedCSS|raw|sw_sanitize) : '' }}
  379.             </style>
  380.         {% endblock %}
  381.         {% block neno_hero_slider_init_script %}
  382.         <script type="text/javascript">
  383.             (function () {
  384.                 var forcePOnP = '{{ config.forceLoadPortraitImagesOnPortraitDevices }}' === '1';
  385.                 var forceLOnL = '{{ config.forceLoadPortraitImagesOnPortraitDevices }}' === '1';
  386.                 // load first image without waiting for main script execution
  387.                 var firstSlideImage = document.querySelector('img.hero-slider-image');
  388.                 function loadLandscapeImage() {
  389.                     var lsSrcSet = firstSlideImage.getAttribute('data-srcset-landscape');
  390.                     var lsSrc = firstSlideImage.getAttribute('data-src-landscape');
  391.                     if (lsSrcSet) {
  392.                         firstSlideImage.srcSet = lsSrcSet;
  393.                     } else if (lsSrc) {
  394.                         firstSlideImage.src = lsSrc;
  395.                     }
  396.                 }
  397.                 function loadPortraitImage() {
  398.                     var poSrcSet = firstSlideImage.getAttribute('data-srcset-portrait');
  399.                     var poSrc = firstSlideImage.getAttribute('data-src-portrait');
  400.                     if (poSrcSet) {
  401.                         firstSlideImage.srcSet = poSrcSet;
  402.                     } else if (poSrc) {
  403.                         firstSlideImage.src = poSrc;
  404.                     }
  405.                 }
  406.                 function fillHeight(el) {
  407.                     var vRect = el.getBoundingClientRect();
  408.                     el.style.height = (window.innerHeight - vRect.top) + 'px';
  409.                 }
  410.                 var el = document.querySelector('.hero-slider');
  411.                 var hsmLandscape = '{{ config.heightScaleMode }}';
  412.                 var hsmPortrait = '{{ config.heightScaleModePortrait }}';
  413.                 var hasFixedAspectL = hsmLandscape === 'fixed_aspect';
  414.                 var hasFixedAspectP = hsmPortrait === 'inherit' ? hasFixedAspectL : (hsmPortrait === 'fixed_aspect');
  415.                 var windowAspect = window.innerWidth / window.innerHeight;
  416.                 var isViewportP = (windowAspect < 1);
  417.                 var initWidth = el.getBoundingClientRect().width;
  418.                 // prime slider height
  419.                 if (isViewportP) {
  420.                     if (hasFixedAspectP) {
  421.                         el.style.height = (1 / {{ aspectRatioPortrait }} * (initWidth || window.innerWidth)) + 'px';
  422.                     } else {
  423.                         fillHeight(el);
  424.                     }
  425.                 } else {
  426.                     if (hasFixedAspectL) {
  427.                         el.style.height = (1 / {{ aspectRatioLandscape }} * (initWidth || window.innerWidth)) + 'px';
  428.                     } else {
  429.                         fillHeight(el);
  430.                     }
  431.                 }
  432.                 if (firstSlideImage) {
  433.                     if ('objectFit' in firstSlideImage.style) {
  434.                         firstSlideImage.style.objectFit = 'cover';
  435.                         firstSlideImage.style.objectPosition = 'center center';
  436.                     }
  437.                     if (isViewportP && forcePOnP) {
  438.                         loadPortraitImage();
  439.                     } else if (!isViewportP && forceLOnL) {
  440.                         loadLandscapeImage();
  441.                     } else {
  442.                         var bRect = el.getBoundingClientRect();
  443.                         var boxAspectRatio = (bRect.width / bRect.height);
  444.                         if (boxAspectRatio < 1) {
  445.                             loadPortraitImage();
  446.                         } else {
  447.                             loadLandscapeImage();
  448.                         }
  449.                     }
  450.                     firstSlideImage.classList.add('hs-image-loaded');
  451.                 }
  452.             })();
  453.         </script>
  454.         {% endblock %}
  455.         {% endif %}
  456.     {% endif %}
  457.     {% endblock %}
  458.     {{ parent() }}
  459. {% endblock %}