templates/includes/media/video.html.twig line 1

Open in your IDE?
  1. {% set videoThumbnail = videoThumbnail|default(false) %}
  2. {% set video = video|default(false) %}
  3. {% set videoDescription = videoDescription|default('') %}
  4. {% set imageThumbnail = imageThumbnail|default(false) %}
  5. {% set image = image|default(false) %}
  6. {% set aspectRatio = aspectRatio|default('16x9') %}
  7. {% set className = className|default('video__container js-video') %}
  8. {% set videoClass = videoClass|default('') %}
  9. {% set attributes = attributes|default([]) %}
  10. {% set removeAttributes = removeAttributes|default([]) %}
  11. {% set isLightbox = isLightbox|default(false) %}
  12. {% if editmode and not video|default('') %}
  13.     {{ pimcore_video('video', {
  14.         'height': 500,
  15.         'allowedTypes': ['asset', 'youtube'],
  16.         'youtube': {
  17.             'modestbranding': true,
  18.         },
  19.     }) }}
  20.     Vorschaubild Youtube-Video:
  21.     {{ pimcore_image('video-preview') }}
  22. {% endif %}
  23. {% if not editmode %}
  24.     {% if not pimcore_video('video').isEmpty() or video != '' %}
  25.         {% set displayVideo = pimcore_video('video').isEmpty() ? video : pimcore_video('video') %}
  26.         {% if displayVideo.getType() != 'asset' %}
  27.             {% set config = {
  28.                 'thumbnail': videoThumbnail,
  29.                 'imagethumbnail': imageThumbnail,
  30.                 'width': '100%',
  31.                 'height': '100%',
  32.                 'attributes': {'class': 'asset-video js-video__video' ~ videoClass}|merge (attributes),
  33.                 'removeAttributes': removeAttributes
  34.             } %}
  35.         {% else %}
  36.             {% set config = {
  37.                 'thumbnail': videoThumbnail,
  38.                 'imagethumbnail': imageThumbnail,
  39.                 'width': '100%',
  40.                 'height': '100%',
  41.                 'attributes': {'class': 'ratio-item'},
  42.                 'removeAttributes': removeAttributes
  43.             } %}
  44.         {% endif %}
  45.         {% if image %}
  46.             {% do displayVideo.setPoster(image) %}
  47.         {% endif %}
  48.         {% if displayVideo is instanceof ('\\Pimcore\\Model\\Asset\\Video') %}
  49.             {% set displayVideo = elements_videoHelper().getVideoTag(displayVideo, config) %}
  50.         {% elseif displayVideo is instanceof ('\\Pimcore\\Model\\DataObject\\Data\\Video') %}
  51.             {% set displayVideo = elements_videoHelper().getVideoTag(displayVideo, config) %}
  52.         {% else %}
  53.             {% do displayVideo.setConfig(config) %}
  54.         {% endif %}
  55.         {% if isLightbox == true %}
  56.             {% do jsConfig().add('lightbox', true) %}
  57.             <div class="js-lightbox {{ className }} ratio ratio-{{ aspectRatio }}" data-lightbox-video="true">
  58.                 {% if displayVideo.getVideoType() == 'asset' %}
  59.                     {% set source = pimcore_asset(elements_videoHelper().getVideoUrl(displayVideo)) %}
  60.                     <a href="" data-video='{"source": [{"src":"{{ source.fullpath }}", "type":"{{ source.mimeType }}"}], "attributes": {"preload": false, "controls": true}}'
  61.                         class="ratio-item js-lightbox__item lg-html5 d-block" aria-label="{{ 'lightbox.video.Open'|trans }}" data-sub-html="{{ videoDescription }}">
  62.                         {% if image %}
  63.                             {% set image = image %}
  64.                         {% else %}
  65.                             {% set image = displayVideo.getPosterAsset() %}
  66.                         {% endif %}
  67.                         {% if image %}
  68.                             {{ image.getThumbnail('media-area').getHtml({
  69.                                 imgAttributes: {
  70.                                     class: 'js-lazy-img ratio-item media-video shadow'
  71.                                 },
  72.                                 lowQualityPlaceholder: true
  73.                             })|raw }}
  74.                             <button type="button" class="box-shadow-hover btn-play">
  75.                                 <span class="btn-play__icon icon icon-play" aria-label="{{ 'global.openVideoPlayer'|trans }}"></span>
  76.                                 <span class="btn-play__text">{{ 'global.playVideo'|trans }}</span>
  77.                             </button>
  78.                         {% endif %}
  79.                     </a>
  80.                 {% else %}
  81.                     {% set sourceExternalVideo = elements_videoHelper().getVideoUrl(displayVideo) %}
  82.                     {% set videoUrl = elements_videoHelper().getVideoUrl(displayVideo) %}
  83.                     {% set src = elements_videoHelper().getYoutubePoster(videoUrl|split('/')|last) %}
  84.                     {% if not pimcore_image('video-preview').isEmpty() %}
  85.                         {% set src = pimcore_image('video-preview').getThumbnail('media-area') %}
  86.                     {% endif %}
  87.                     {% embed('@ElementsCmsTools/consent-overlay.html.twig') with {
  88.                         'classNames': {
  89.                             'wrapper': 'consent ratio-item',
  90.                             'overlay': 'consent__overlay ratio-item',
  91.                             'template': 'ratio-item',
  92.                         },
  93.                         'service': 'marketing',
  94.                         'buttonText': 'cookies.Marketingcookies akzeptieren'|trans,
  95.                         'overlayText': 'cookies.Um das Video anzusehen, müssen Sie die Cookies akzeptieren'|trans
  96.                     } %}
  97.                         {% block consentIframe %}
  98.                                 <a href="" data-src="{{ sourceExternalVideo }}" class="js-lightbox__item ratio-item">
  99.                                     <img src="{{ src }}" class="ratio-item media-video shadow" alt="{{ videoDescription }}"/>
  100.                                     <button type="button" class="box-shadow-hover btn-play">
  101.                                         <span class="btn-play__icon icon icon-play" aria-label="{{ 'global.openVideoPlayer'|trans }}"></span>
  102.                                         <span class="btn-play__text">{{ 'global.playVideo'|trans }}</span>
  103.                                     </button>
  104.                                 </a>
  105.                         {% endblock %}
  106.                     {% endembed %}
  107.                 {% endif %}
  108.             </div>
  109.         {% else %}
  110.             <div class="d-block {{ className }} {{ aspectRatio ? 'ratio ratio-' ~ aspectRatio }}">
  111.                 {% if displayVideo.getVideoType()|default(displayVideo.getType()) == 'asset' %}
  112.                     {{ displayVideo|raw }}
  113.                     <button type="button" class="box-shadow-hover btn-play">
  114.                         <span class="btn-play__icon icon icon-play" aria-label="{{ 'global.openVideoPlayer'|trans }}"></span>
  115.                         <span class="btn-play__text">{{ 'global.playVideo'|trans }}</span>
  116.                     </button>
  117.                 {% else %}
  118.                     {% embed('@ElementsCmsTools/consent-overlay.html.twig') with {
  119.                         'service': 'marketing',
  120.                         'buttonText': 'cookies.Marketingcookies akzeptieren'|trans,
  121.                         'overlayText': 'cookies.Um das Video anzusehen, müssen Sie die Cookies akzeptieren'|trans
  122.                     } %}
  123.                         {% block consentIframe %}
  124.                             {{ displayVideo|raw }}
  125.                         {% endblock %}
  126.                     {% endembed %}
  127.                 {% endif %}
  128.             </div>
  129.         {% endif %}
  130.     {% endif %}
  131. {% endif %}