AfterImageResourceResolvedEvent

New in version 13.0

The PSR-14 event \TYPO3\CMS\Frontend\ContentObject\Event\AfterImageResourceResolvedEvent is being dispatched just before ContentObjectRenderer->getImgResource() is about to return the resolved \TYPO3\CMS\Core\Imaging\ImageResource DTO. Therefore, the event is - in comparison to the removed hook - always dispatched, even if no ImageResource could be resolved. In this case, the corresponding return value is null.

Example

EXT:my_extension/Classes/Frontend/EventListener/MyEventListener.php
<?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);
    }
}
Copied!

New in version 13.0

API

class AfterImageResourceResolvedEvent
Fully qualified name
\TYPO3\CMS\Frontend\ContentObject\Event\AfterImageResourceResolvedEvent

Listeners are able to modify the resolved ContentObjectRenderer->getImgResource() result

getFile ( )
Returns
\TYPO3\CMS\Core\Resource\File|\TYPO3\CMS\Core\Resource\FileReference|string
getFileArray ( )
Returns
array
getImageResource ( )
Returns
?\TYPO3\CMS\Core\Imaging\ImageResource
setImageResource ( ?\TYPO3\CMS\Core\Imaging\ImageResource $imageResource)
param $imageResource

the imageResource