Feature: #97230 - PSR-14 event for modifying image manipulation preview URL
See forge#97230
Description
A new PSR-14 event \TYPO3\
has been introduced which serves as a direct replacement for the now removed
$GLOBALS
hook.
It can be used to modify the preview URL within the image manipulation element,
used e.g. for the crop
field of the sys_
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 Cancel and Accept buttons. On click, the preview URL will be opened in a new window.
Note
The element's crop variants will always be appended to the preview URL
as JSON-encoded string, using the crop
parameter.
Next to the get
and set
the new
PSR-14 event feature the following methods:
get
: Returns the whole database row for the corresponding recordDatabase Row () get
: Returns the processed field configurationField Configuration () get
: Returns the resolved file objectFile ()
Example
Registration of the event in your extension's Services.
:
MyVendor\MyPackage\Backend\MyEventListener:
tags:
- name: event.listener
identifier: 'my-package/backend/modify-imagemanipulation-previewurl'
The corresponding event listener class:
use TYPO3\CMS\Backend\Form\Event\ModifyImageManipulationPreviewUrlEvent;
final class MyEventListener
{
public function __invoke(ModifyImageManipulationPreviewUrlEvent $event): void
{
$event->setPreviewUrl('https://example.com/some/preview/url');
}
}
Impact
It's now possible to modify the preview URL for the image manipulation
element, using the new PSR-14 event Modify
.