---
title: "Feature: #102755 - PSR-14 event for modifying getImageResource result"
manual: "TYPO3 Core Changelog"
version: "main"
permalink: "https://docs.typo3.org/permalink/changelog:feature-102755-1704381990"
source: "Changelog/13.0/Feature-102755-PSR-14EventForModifyingGetImageResourceResult.rst"
typo3-version: "13.0"
typo3-major: 13
type: "feature"
issue: 102755
forge: "https://forge.typo3.org/issues/102755"
tags: ["Frontend", "PHP-API", "ext:frontend"]
rendered: "2026-09-20T18:31:11+00:00"
---

# Feature: #102755 - PSR-14 event for modifying getImageResource result {#feature-102755-1704381990}

See [forge#102755](https://forge.typo3.org/issues/102755)

## Description {#description}

A new PSR-14 event `\TYPO3\CMS\Frontend\ContentObject\Event\AfterImageResourceResolvedEvent`
has been introduced which serves as a replacement for the now removed
hook `$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['getImgResource']`.

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

> [!NOTE]
> Instead of an `array` `ContentObjectRenderer` now handles
> the image resource with the new `ImageResource` DTO.
> This means, `ContentObjectRenderer->getImgResource()` returns either the new
> DTO or null.

To modify the `getImgResource()` result, the following methods are available:

-   `setImageResource()`: Allows to set the `ImageResource` to return
-   `getImageResource()`: Returns the resolved `ImageResource` or `null`
-   `getFile()`: Returns the `$file`, passed to the `getImageResource` function
-   `getFileArray()`: Returns the `$fileArray`, passed to the `getImageResource` function

## Example {#example}

The event listener class, using the PHP attribute `#[AsEventListener]` for
registration:

```php
use TYPO3\CMS\Core\Attribute\AsEventListener;
use TYPO3\CMS\Frontend\ContentObject\Event\AfterImageResourceResolvedEvent;

final class AfterImageResourceResolvedEventListener
{
    #[AsEventListener]
    public function __invoke(AfterImageResourceResolvedEvent $event): void
    {
        $modifiedImageResource = $event
            ->getImageResource()
            ->withWidth(123);

        $event->setImageResource($modifiedImageResource);
    }
}
```

## Impact {#impact}

Using the new PSR-14 Event, it's now possible to modify the resolved
`getImageResource()` result.

Additionally, the `ImageResource` DTO allows an improved API as
developers do no longer have to deal with unnamed array keys but benefit
from the object-oriented approach, using corresponding getter and setter.
