{% from '@Provider/macros/media_edit.html.twig' import media_edit as conecto_media_edit %}
<div class="header-media">
{% if editmode %}
{{ conecto_media_edit(
'header_',
1920,
1080
) }}
{% else %}
{% set headerImage = pimcore_image('header_image').getImage() %}
{% set headerVideo = pimcore_video('header_video').getVideoAsset() %}
{% if not headerImage and not headerVideo %}
{# Parent Fallback #}
{% set headerImage = conecto_get_parent_editable(document, 'header_image') %}
{% set headerVideo = headerImage ? null : conecto_get_parent_editable(document, 'header_video') %}
{% if headerImage or headerVideo %}
{% set parentDocument = (headerImage ? headerImage.getDocument() : (headerVideo ? headerVideo.getDocument() : null) ) %}
{% set headerImage = headerImage ? headerImage.getImage() : null %}
{% set headerVideo = headerVideo ? headerVideo.getVideoAsset() : null %}
{% endif %}
{% endif %}
{% endif %}
{% if headerImage is defined and headerImage is instanceof('\\Pimcore\\Model\\Asset\\Image') %}
{{ headerImage.getThumbnail('headerImage').getHTML()|raw }}
{% endif %}
{% if headerVideo is defined and headerVideo is instanceof('\\Pimcore\\Model\\Asset\\Video') %}
{# YouTube usw. werden hier bewusst ignoriert, da im Header suboptimal - wenn vom Kunden gewünscht -> individuell umsetzen #}
<video src="{{ headerVideo }}"{% if not editmode %} autoplay loop muted playsinline{% endif %}></video>
{% endif %}
{% if editmode or pimcore_input('header_title') != '' %}
<div class="header-media--content">
{% if (pimcore_input('header_title') != "") %}
<h2>{{ pimcore_input('header_title', { "placeholder": "Titel" }) }}</h2>
{% endif %}
{% if (pimcore_input('header_subtitle') != "") %}
<p>{{ pimcore_input('header_subtitle', { "placeholder": "Untertitel" }) }}</p>
{% endif %}
{{ pimcore_link('header_link', {
"class": "btn-primary"
}) }}
</div>
{% elseif parentDocument is defined and parentDocument is instanceof('\\Pimcore\\Model\\Document') %}
{# Parent Fallback #}
<div class="header-media--content">
{% if conecto_get_editable(parentDocument, 'header_title') != "" %}
<h2>{{ conecto_get_editable(parentDocument, 'header_title') }}</h2>
{% endif %}
{% if conecto_get_editable(parentDocument, 'header_subtitle') != "" %}
<p>{{ conecto_get_editable(parentDocument, 'header_subtitle') }}</p>
{% endif %}
{% if conecto_get_editable(parentDocument, 'header_link') != "" %}
{{ conecto_get_editable(parentDocument, 'header_link') }}
{% endif %}
</div>
{% endif %}
</div>