{% block acris_product_video_iframe_youtube %}
{% if config('AcrisProductVideoCS.config').hideRelatedVideos == true %}
{% if '?' in image.translated.link %}
{% do image.addTranslated('link', image.translated.link~'&rel=0') %}
{% else %}
{% do image.addTranslated('link', image.translated.link~'?rel=0') %}
{% endif %}
{% endif %}
{% set previewImageLoading = config('AcrisProductVideoCS.config').previewImageLoading %}
{% set previewImageUrl = null %}
{% if image.extensions.acrisProductVideoPreviewImage and image.extensions.acrisProductVideoPreviewImage.media %}
{% set previewImageUrl = image.extensions.acrisProductVideoPreviewImage.media.url %}
{% endif %}
{% set customImg = false %}
{% if previewImageLoading == 'cookie' %}
{% set customImg = true %}
{% endif %}
{% set productVideoImg = 'https://i.ytimg.com/vi/' ~ image.translated.link|split('/')|last|split('?')|first|trim ~ '/hqdefault.jpg' %}
{% if image.type == 'youtube' %}
{% set type = 'youtube' %}
{% else %}
{% set type = 'vimeo' %}
{% endif %}
{% set productVideoOptions = {
loadVideoAfterClick: loadVideoAfterClick,
errorCookieSource: "https://www.youtube-nocookie.com/embed/error",
noCookieVideo: noCookie|length,
previewImageLoading: previewImageLoading,
previewImageUrl: previewImageUrl,
productVideoId: image.id,
entry: 'element',
type: type,
customImg: customImg,
currentPreviewImage: productVideoImg,
originalSource: image.translated.link
} %}
<div itemscope itemtype="http://schema.org/VideoObject"
class="element-product-video-id-{{ image.id }} acris-product-video-item-container is-{{ displayMode }}{% if isImageGallery %} gallery-slider-item-container{% endif %}"{% if minHeight and (displayMode == "cover" or displayMode == "contain" ) %} style="height: {{ minHeight }}"{% endif %}>
<meta itemprop="name" content="{{ metaUrlData['title'] }}" />
<meta itemprop="thumbnailURL" content="{{ metaUrlData['thumbnail_url'] }}" />
<meta itemprop="uploadDate" content="{{ image.createdAt.format('Y-m-dTH:i:sZ') }}"/>
<meta itemprop="embedURL" content="{{ image.translated.link }}" />
<meta itemprop="description" content="{{ metaUrlData['description'] }}" />
<iframe class="acris-product-video-iframe"
title="{{ image.translated.description }}"
data-acris-product-video="true"
data-acris-product-video-options="{{ productVideoOptions|json_encode }}"
src="{{ image.translated.link }}" width="460" height="285" frameborder="0"
allowfullscreen="allowfullscreen"
mozallowfullscreen="mozallowfullscreen"
msallowfullscreen="msallowfullscreen"
oallowfullscreen="oallowfullscreen"
webkitallowfullscreen="webkitallowfullscreen"></iframe>
</div>
{% set loadVideoWithNoCookie = true %}
{% set loadVideoAfterClick = 'loadAfter' %}
{% sw_include '@AcrisProductVideoCS/storefront/component/custom/element/iframe-youtube-load-after.html.twig' %}
{% endblock %}