Feature: #97230 - PSR-14 Event for modifying image manipulation preview url

See forge#97230

Description

A new PSR-14 Event \TYPO3\CMS\Backend\Form\Event\ModifyImageManipulationPreviewUrlEvent has been introduced which serves as a direct replacement for the now removed $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['Backend/Form/Element/ImageManipulationElement']['previewUrl'] 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_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 Cancel and 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.

Next to the getPreviewUrl() and setPreviewUrl() does the new PSR-14 Event feature the following methods:

  • getDatabaseRow(): Returns the whole database row for the corresponding record

  • getFieldConfiguration(): Returns the processed field configuration

  • getFile(): Returns the resolved file object

Example

Registration of the Event in your extensions' Services.yaml:

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 ModifyImageManipulationPreviewUrlEvent.