diff --git a/src/core/Form/Site/Page/FileBlockType.php b/src/core/Form/Site/Page/FileBlockType.php index a2a0836..104a057 100644 --- a/src/core/Form/Site/Page/FileBlockType.php +++ b/src/core/Form/Site/Page/FileBlockType.php @@ -29,7 +29,7 @@ class FileBlockType extends TextBlockType public function buildView(FormView $view, FormInterface $form, array $options) { $view->vars = array_replace($view->vars, [ - 'is_image' => $options['is_image'], + 'file_type' => $options['file_type'], ]); } @@ -37,7 +37,7 @@ class FileBlockType extends TextBlockType { $resolver->setDefaults([ 'data_class' => FileBlock::class, - 'is_image' => false, + 'file_type' => 'auto', 'options' => [], ]); } diff --git a/src/core/Resources/views/form/bootstrap_4_form_theme.html.twig b/src/core/Resources/views/form/bootstrap_4_form_theme.html.twig index 7761c09..22d2b85 100644 --- a/src/core/Resources/views/form/bootstrap_4_form_theme.html.twig +++ b/src/core/Resources/views/form/bootstrap_4_form_theme.html.twig @@ -11,10 +11,15 @@
{% set value = form.vars.data %} - {% set isImage = form.parent.vars.is_image is defined and form.parent.vars.is_image %} + + {% if form.parent.vars.file_type is defined %} + {% set fileType = form.parent.vars.file_type %} + {% else %} + {% set fileType = 'auto' %} + {% endif %} {% if value %} - {% if isImage and value and value.extension in ['jpeg', 'jpg', 'gif', 'png', 'svg'] %} + {% if fileType in ['auto', 'image'] and value.extension in ['jpeg', 'jpg', 'gif', 'png', 'svg'] %}