-
Notifications
You must be signed in to change notification settings - Fork 398
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE] Feature: #97230 - PSR-14 Event for modifying image manipula… (
#1796) * [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 #1624 * Update ModifyImageManipulationPreviewUrlEvent.rst Co-authored-by: lina.wolf <[email protected]>
- Loading branch information
Showing
2 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
...ion/ApiOverview/Hooks/Events/Backend/ModifyImageManipulationPreviewUrlEvent.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...tion/CodeSnippets/Events/Backend/ModifyImageManipulationPreviewUrlEvent.rst.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|