ebs/templates/easy_admin/field/flysystem_images.html.twig
2023-12-21 08:49:38 +01:00

27 lines
1.2 KiB
Twig

{# @var ea \EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext #}
{# @var field \EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto #}
{# @var entity \EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto #}
{# We need the raw value here (an array because the extensions handle the public_url() prefix #}
{% set images = field.value %}
{% if images is not iterable %}
{% set images = [images] %}
{% endif %}
{# Check if we want to display one image or multiple ones #}
{% if field.customOption('first_image_only') == true %}
{% set images = images|slice(0, 1) %}
{% endif %}
{% for image in images %}
{% if image is not empty %}
{% set html_id = 'ea-lightbox-' ~ field.uniqueId ~ '-' ~ loop.index %}
<a href="#" onclick="return false;" class="ea-lightbox-thumbnail" data-ea-lightbox-content-selector="#{{ html_id }}">
<img src="{{ entity.instance|public_url_image(image) }}" class="img-fluid" alt="{{ entity.instance.name ?? '' }}">
</a>
<div id="{{ html_id }}" class="ea-lightbox">
<img src="{{ entity.instance|public_url_image(image) }}" alt="{{ entity.instance.name ?? '' }}">
</div>
{% endif %}
{% endfor %}