Skip to content

Commit

Permalink
[FEATURE] Feature: #97230 - PSR-14 Event for modifying image manipula… (
Browse files Browse the repository at this point in the history
#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
linawolf and linawolf authored Apr 6, 2022
1 parent 925f9ad commit bef7af7
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 0 deletions.
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');
}
}
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

0 comments on commit bef7af7

Please sign in to comment.