From 3696c6b26d4812c70b2deb90e87835497f5e542b Mon Sep 17 00:00:00 2001 From: Benoit Jouhaud Date: Fri, 27 Oct 2023 12:05:50 +0200 Subject: [PATCH] Issue #96: Allow setting the download_uri manually --- README.md | 2 +- src/Form/Type/ImageType.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index cbc7094..5906116 100644 --- a/README.md +++ b/README.md @@ -127,7 +127,7 @@ Available options for the `ImageType`: - `cancel_button_class` (`string`): class of the button (default: `''`) - `save_button_class` (`string`): class of the button (default: `''`) - `download_uri` (`string`): the path where the image is located (default: `null`, automatically set) -- `download_link` (`bool`): whether the end user should be able to add a remote image by URL or not (default: `true`) +- `download_link` (`bool`): whether the image should be rendered in the form or not (default: `true`) - `file_upload_enabled` (`bool`): whether to enable the file upload widget or not (default: `true`) - `remote_url_enabled` (`bool`): whether to enable the remote url widget or not (default: `true`) - `rotation_enabled` (`bool`): whether to enable the rotation or not (default: `false`) diff --git a/src/Form/Type/ImageType.php b/src/Form/Type/ImageType.php index dd8804c..a40d844 100644 --- a/src/Form/Type/ImageType.php +++ b/src/Form/Type/ImageType.php @@ -169,8 +169,8 @@ public function buildView(FormView $view, FormInterface $form, array $options): $view->vars['upload_mimetype'] = $options['upload_mimetype']; $view->vars['upload_quality'] = $options['upload_quality']; - if ($options['download_link'] && $downloadUri = $this->generateDownloadUri($form)) { - $view->vars['download_uri'] = $downloadUri; + if ($options['download_link']) { + $view->vars['download_uri'] = $options['download_uri'] ?? $this->generateDownloadUri($form); } }