AfterImageResourceResolvedEvent
New in version 13.0
This event serves as a drop-in replacement for the removed hook
$GLOBALS
.
The PSR-14 event
\TYPO3\
is being dispatched just before Content
is about to return the resolved \TYPO3\
DTO. Therefore, the event is - in comparison to
the removed hook - always dispatched, even if no Image
could be
resolved. In this case, the corresponding return value is null
.
Example
<?php
declare(strict_types=1);
namespace MyVendor\MyExtension\Frontend\EventListener;
use TYPO3\CMS\Core\Attribute\AsEventListener;
use TYPO3\CMS\Frontend\ContentObject\Event\AfterImageResourceResolvedEvent;
#[AsEventListener(
identifier: 'my-extension/my-event-listener',
)]
final readonly class MyEventListener
{
public function __invoke(AfterImageResourceResolvedEvent $event): void
{
$modifiedImageResource = $event
->getImageResource()
->withWidth(123);
$event->setImageResource($modifiedImageResource);
}
}
New in version 13.0
The PHP attribute \TYPO3\
has been
introduced to tag a PHP class as an event listener. Alternatively, you can also
register an event listener via the Configuration/
file. Have
a look into the section Implementing an event listener in your extension.