{% from '@Provider/macros/media.html.twig' import media as conecto_media %}
{% from '@Provider/macros/media_edit.html.twig' import media_edit as conecto_media_edit %}
{# Default block settings #}
{% set class = pimcore_input('class').getData() %}
{% set marginTop = pimcore_select('margin_top').getData() %}
{% set marginBottom = pimcore_select('margin_bottom').getData() %}
{% set containerWidth = pimcore_select('container_width').getData() %}
{% set areaClass = class ~ ' ' ~ marginTop ~ ' ' ~ marginBottom ~ ' ' ~ containerWidth %}
{% set anchorId = pimcore_input('anchor').getData() %}
{# Block specific settings #}
{% set position = pimcore_select('position').getData() %}
{% set mediaWidth = pimcore_select('media_width').getData() ? pimcore_select('media_width').getData() : 50 %}
{% set textWidth = pimcore_select('media_width').getData() ? (100 - pimcore_select('media_width').getData()) : 50 %}
{% set colRatio = position == 'right' ? textWidth ~ '-' ~ mediaWidth : mediaWidth ~ '-' ~ textWidth %}
{% set imageRatio = pimcore_select('ratio').getData() ? pimcore_select('ratio').getData() : 3/2 %}
{% set showLightbox = not pimcore_checkbox('no_lightbox').isChecked() %}
{% set showCopyright = pimcore_checkbox('copyright').isChecked() %}
{% set showCaption = pimcore_checkbox('caption').isChecked() %}
{# Special video settings #}
{% set videoAddAttributes = {} %}
{% set videoRemoveAttributes = pimcore_checkbox('controls').isChecked() ? [] : ['controls'] %}
{% if pimcore_checkbox('autoplay').isChecked() %}{% set videoAddAttributes = videoAddAttributes|merge({autoplay: '', playsinline: ''}) %}{% endif %}
{% if pimcore_checkbox('loop').isChecked() %}{% set videoAddAttributes = videoAddAttributes|merge({loop: ''}) %}{% endif %}
{% if pimcore_checkbox('mute').isChecked() %}{% set videoAddAttributes = videoAddAttributes|merge({muted: ''}) %}{% endif %}
<div class="area area--textmedia {{ areaClass }}{{ pimcore_checkbox('highlight').isChecked() ? ' highlight' : '' }}"{% if anchorId %} id="{{ anchorId }}"{% endif %}>
<div class="cols cols--2 thumbnail--{{ position }}{% if colRatio is not empty %} ratio--{{ colRatio }}{% endif %}">
<figure class="area--thumbnail col">
{% if editmode %}
{{ conecto_media_edit(
'textmedia_',
(1920 * mediaWidth / 100),
(1920 * mediaWidth / 100) / imageRatio
) }}
{% else %}
{% if not pimcore_image('textmedia_image').isEmpty() %}
{{ conecto_media(
pimcore_image('textmedia_image').getImage(),
editmode,
showLightbox,
showCopyright,
showCaption,
{
thumbName: 'textMedia',
ratio: imageRatio,
cols: 100 / mediaWidth,
widgetAltText: pimcore_image('textmedia_image').getAlt()
}
) }}
{% endif %}
{% if not pimcore_video('textmedia_video').isEmpty() %}
{{ pimcore_video('textmedia_video', {
"width": "100%",
"height": "100%",
"attributes": videoAddAttributes,
"removeAttributes": videoRemoveAttributes
}) }}
{% endif %}
{% endif %}
</figure>
<div class="area--text area--textmedia--text col">
<div class="area--text--inner">
{{ pimcore_wysiwyg('text') }}
{% if editmode %}
{{ pimcore_link('link', { 'reload': true }) }}
{% endif %}
{% if not pimcore_link('link').isEmpty() %}
<p>
<a href="{{ pimcore_link('link').getHref() }}" class="btn btn-{% if pimcore_link('link').getClass() %}{{ pimcore_link('link').getClass() }}{% else %}primary{% endif %}" {% if pimcore_link('link').getTarget() %}target="{{ pimcore_link('link').getTarget() }}"{% endif %}>
{{ pimcore_link('link').getText() }}
</a>
</p>
{% endif %}
</div>
</div>
</div>
</div>