From bef7af75abf4440e709bb3b66b12adac3c77c3d9 Mon Sep 17 00:00:00 2001 From: Lina Wolf <48202465+linawolf@users.noreply.github.com> Date: Wed, 6 Apr 2022 14:20:23 +0200 Subject: [PATCH] =?UTF-8?q?[FEATURE]=20Feature:=20#97230=20-=20PSR-14=20Ev?= =?UTF-8?q?ent=20for=20modifying=20image=20manipula=E2=80=A6=20(#1796)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [FEATURE] Feature: #97230 - PSR-14 Event for modifying image manipulation preview url https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/12.0/Feature-97230-PSR-14EventForModifyingImageManipulationPreviewUrl.html refs https://github.com/TYPO3-Documentation/TYPO3CMS-Reference-CoreApi/issues/1624 * Update ModifyImageManipulationPreviewUrlEvent.rst Co-authored-by: lina.wolf --- ...ModifyImageManipulationPreviewUrlEvent.rst | 61 +++++++++++++++++++ ...fyImageManipulationPreviewUrlEvent.rst.txt | 28 +++++++++ 2 files changed, 89 insertions(+) create mode 100644 Documentation/ApiOverview/Hooks/Events/Backend/ModifyImageManipulationPreviewUrlEvent.rst create mode 100644 Documentation/CodeSnippets/Events/Backend/ModifyImageManipulationPreviewUrlEvent.rst.txt diff --git a/Documentation/ApiOverview/Hooks/Events/Backend/ModifyImageManipulationPreviewUrlEvent.rst b/Documentation/ApiOverview/Hooks/Events/Backend/ModifyImageManipulationPreviewUrlEvent.rst new file mode 100644 index 0000000000..e39ea669dc --- /dev/null +++ b/Documentation/ApiOverview/Hooks/Events/Backend/ModifyImageManipulationPreviewUrlEvent.rst @@ -0,0 +1,61 @@ +.. include:: /Includes.rst.txt +.. index:: + Events; ModifyImageManipulationPreviewUrlEvent +.. _ModifyImageManipulationPreviewUrlEvent: + +============================================ +ModifyImageManipulationPreviewUrlEvent +============================================ + +.. versionadded:: 12.0 + This event serves as a direct replacement for the now removed + :php:`$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['Backend/Form/Element/ImageManipulationElement']['previewUrl']` + hook. + +This event can be used to modify the preview url within the image manipulation +element, used for example for the :php:`crop` field of the +:sql:`sys_file_reference` table. + +As soon as a preview url is set, the image manipulation element will display +a corresponding button in the footer of the modal window, next to the +:guilabel:`Cancel` and :guilabel:`Accept` buttons. On click, the preview +url will be opened in a new window. + +.. note:: + + The elements crop variants will always be appended to the preview url + as json encoded string, using the `cropVariants` parameter. + +API +=== + +.. include:: /CodeSnippets/Events/Backend/ModifyImageManipulationPreviewUrlEvent.rst.txt + + +Example +======= + +Registration of the Event in your extensions' :file:`Services.yaml`: + +.. code-block:: yaml + :caption: EXT:my_extension/Configuration/Services.yaml + + MyVendor\MyExtension\Backend\ModifyLinkExplanationEventListener: + tags: + - name: event.listener + identifier: 'my-extension/backend/modify-imagemanipulation-previewurl' + +The corresponding event listener class: + +.. code-block:: php + :caption: EXT:my_extension/Classes/Backend/ModifyLinkExplanationEventListener.php + + use TYPO3\CMS\Backend\Form\Event\ModifyImageManipulationPreviewUrlEvent + + final class ModifyLinkExplanationEventListener + { + public function __invoke(ModifyImageManipulationPreviewUrlEvent $event): void + { + $event->setPreviewUrl('https://example.com/some/preview/url'); + } + } diff --git a/Documentation/CodeSnippets/Events/Backend/ModifyImageManipulationPreviewUrlEvent.rst.txt b/Documentation/CodeSnippets/Events/Backend/ModifyImageManipulationPreviewUrlEvent.rst.txt new file mode 100644 index 0000000000..3225ac18ee --- /dev/null +++ b/Documentation/CodeSnippets/Events/Backend/ModifyImageManipulationPreviewUrlEvent.rst.txt @@ -0,0 +1,28 @@ +.. Generated by https://github.com/linawolf/t3docs_restructured_api_tools +.. php:namespace:: TYPO3\CMS\Backend\Form\Event + +.. php:class:: ModifyImageManipulationPreviewUrlEvent + + Listeners to this Event will be able to modify the preview url, used in the ImageManipulation element + + + .. php:method:: getDatabaseRow() + + :returntype: array + + .. php:method:: getFieldConfiguration() + + :returntype: array + + .. php:method:: getFile() + + :returntype: TYPO3\\CMS\\Core\\Resource\\File + + .. php:method:: getPreviewUrl() + + :returntype: string + + .. php:method:: setPreviewUrl(string previewUrl) + + :param string $previewUrl: the previewUrl +