templates/Magazine/Includes/articleTeaser.html.twig line 1

Open in your IDE?
  1. {% set video = article.video %}
  2. {% set videoType = article.video.type | default ('') %}
  3. {% set button = button | default(false) %}
  4. {% set title = article.title %}
  5. {% set text = article.shortDescription %}
  6. {% set link = linkGenerator().generate(article, {'relative': relative|default(false), 'document': document}) %}
  7. <section class="article-teaser {{ video ? 'js-lightbox' : '' }} {{ button ? 'stretch-link isCursor' : '' }} {{ areaWide ? 'article-teaser--wide' : '' }}"
  8.     {% if video %}
  9.     data-lightbox-video="true"
  10.     {% endif %}>
  11.     {% do jsConfig().add('lazyImg', true) %}
  12.     {% do jsConfig().add('goToLink', true) %}
  13.     {% if not video %}
  14.         <div class="article-teaser__img-wrapper">
  15.             <div class="embed-responsive {{ areaWide ? 'article-teaser__embed--wide' : 'article-teaser__embed' }}">
  16.                 {% if article.teaserImage %}
  17.                     {{ article.teaserImage.getThumbnail(areaWide ? 'article-teaser--wide' : 'article-teaser').getHtml({
  18.                         imgAttributes: {
  19.                             'class' : 'embed-responsive-item js-lazy-img article-teaser__img'
  20.                         },
  21.                         'lowQualityPlaceholder' : true})
  22.                     | raw
  23.                     }}
  24.                 {% endif %}
  25.             </div>
  26.             {% if article.topArticle  %}
  27.                 {{ include('Magazine/Includes/triangle-badge.html.twig', {
  28.                     'text': article.getAdvertismentNote() ?: ("magazine.top-article.badge" | trans),
  29.                     'position': 'left',
  30.                     'styleModifier': ''
  31.                 }) }}
  32.             {%  endif %}
  33.         </div>
  34.     {% else %}
  35.         {% do jsConfig().add('lightbox', true) %}
  36.         {% do jsConfig().add('video', true) %}
  37.         <div data-html="#videoLightbox-{{ article.id }}" data-sub-html="<div class='lightbox-content__title'>{{ article.videoText }}</div><div class='lightbox-content__text'>{{ article.videoDescription | nl2br }}</div>"
  38.              class="lightbox-video js-lightbox__item {{ videoType == 'asset' ? 'lg-html5': ''}}">
  39.             <div class="article-teaser__img-wrapper">
  40.                 <div class="embed-responsive {{ areaWide ? 'article-teaser__embed--wide' : 'article-teaser__embed' }}">
  41.                     {% if article.teaserImage %}
  42.                         {{ article.teaserImage.getThumbnail(areaWide ? 'article-teaser--wide' : 'article-teaser').getHtml({
  43.                             imgAttributes: {
  44.                                 'class' : 'embed-responsive-item js-lazy-img article-teaser__img'
  45.                             },
  46.                             'lowQualityPlaceholder' : true})
  47.                         | raw
  48.                         }}
  49.                     {% endif %}
  50.                 </div>
  51.                 {% if article.topArticle  %}
  52.                     {{ include('Magazine/Includes/triangle-badge.html.twig', {
  53.                         'text': article.topArticle.getAdvertismentNote() ?: ("magazine.top-article.badge" | trans),
  54.                         'position': 'left',
  55.                         'styleModifier': ''
  56.                     }) }}
  57.                 {%  endif %}
  58.                 <button type="button"
  59.                         class="video__play-btn article-teaser__play-btn"
  60.                         aria-label="{{ 'sr.Open Video'|trans }}"
  61.                         title="{{ 'sr.Open Video'|trans }}">
  62.                     <span class="icon icon-play video__play-btn__icon" aria-hidden="true"></span>
  63.                 </button>
  64.             </div>
  65.         </div>
  66.         <div id="videoLightbox-{{ article.id }}" style="display: none;">
  67.             {% if videoType == 'asset' %}
  68.                 {% set options = {
  69.                     'imagethumbnail': 'lightbox-video-poster',
  70.                     'width': '100%',
  71.                     'height': '100%',
  72.                     'attributes': {
  73.                         'controls': 'controls',
  74.                         'preload': 'none',
  75.                         'class': 'lg-video-object lg-html5 video-js vjs-default-skin'
  76.                     }
  77.                 } %}
  78.                 {% set displayVideo = elements_videoHelper().getVideoTag(video, options) %}
  79.                 {{ displayVideo | raw }}
  80.             {% else %}
  81.                 {% if videoType == 'youtube' %}
  82.                     {% set src = "https://www.youtube-nocookie.com/embed/" ~ elements_videoHelper().getRealYoutubeId(video.data) %}
  83.                 {% endif %}
  84.                 {% if videoType == 'vimeo' %}
  85.                     {% set src = "https://player.vimeo.com/video/" ~ elements_videoHelper().getRealVimeoId(video.data) %}
  86.                 {% endif %}
  87.                 {% if videoType == 'dailymotion' %}
  88.                     {% set src = "https://www.dailymotion.com/embed/video/" ~ video.data %}
  89.                 {% endif %}
  90.                 <iframe class="js-lazy-iframe lightbox-video__iframe"
  91.                         data-src="{{ src|default('') }}"
  92.                         frameborder="0"
  93.                         allow="autoplay; encrypted-media"
  94.                         allowfullscreen></iframe>
  95.             {% endif %}
  96.         </div>
  97.     {% endif %}
  98.     <div class="article-teaser__body">
  99.         <h3 class="article-teaser__title">
  100.             {# if article-teaser has video - no button and no detail-page #}
  101.             {% if not video %}
  102.                 <a href="{{ link }}" class="stretch-link__link">
  103.                     {{ title }}
  104.                 </a>
  105.             {% else %}
  106.                 {{ title }}
  107.             {% endif %}
  108.         </h3>
  109.         <div class="article-teaser__content">
  110.             {{ text }}
  111.         </div>
  112.         {% if not video %}
  113.             <a href="{{ link }}" class="article-teaser__btn btn btn-outline-primary">
  114.                 {{ 'magazine.Artikel lesen' | trans }}
  115.             </a>
  116.         {% endif %}
  117.     </div>
  118. </section>