From abf14fecffa562e646298b6df864ed266bb4804e Mon Sep 17 00:00:00 2001 From: Mathieu Ducrot Date: Mon, 1 Jul 2024 16:04:36 +0200 Subject: [PATCH] Add template for rendering image from Smart\CoreBundle\Entity\EmbeddedFile --- .../base_field/show_embedded_image.html.twig | 16 ++++++++++++++++ translations/admin.fr.xlf | 4 ++++ 2 files changed, 20 insertions(+) create mode 100644 templates/admin/base_field/show_embedded_image.html.twig diff --git a/templates/admin/base_field/show_embedded_image.html.twig b/templates/admin/base_field/show_embedded_image.html.twig new file mode 100644 index 0000000..aeadb89 --- /dev/null +++ b/templates/admin/base_field/show_embedded_image.html.twig @@ -0,0 +1,16 @@ +{# MDT Use this template if you want to display image from Smart\CoreBundle\Entity\EmbeddedFile #} + +{% extends '@SonataAdmin/CRUD/base_show_field.html.twig' %} + +{% block field %} + {% set fileNameValue = value.name %} + {% if fileNameValue is null %} + {% set url = asset('bundles/smartsonata/images/placeholders/128x128.png') %} + {% set alt = 'logo' %} + {% else %} + {% set url = vich_uploader_asset(object.files, field_description.fieldName ~ 'File') %} + {% set alt = value.originalName %} + {% endif %} + + {{ alt }} +{% endblock %} diff --git a/translations/admin.fr.xlf b/translations/admin.fr.xlf index 315b42a..084a073 100644 --- a/translations/admin.fr.xlf +++ b/translations/admin.fr.xlf @@ -185,6 +185,10 @@ label.pdf_file Fichier PDF + + label.image + Image + label.image_updated_at Image mise à jour le