ModifyImageSourceCollectionEvent

New in version 13.0

The PSR-14 event \TYPO3\CMS\Frontend\ContentObject\Event\ModifyImageSourceCollectionEvent is being dispatched in ContentObjectRenderer->getImageSourceCollection() for each configured sourceCollection and allows to enrich the final source collection result.

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\ModifyImageSourceCollectionEvent;

#[AsEventListener(
    identifier: 'my-extension/my-event-listener',
)]
final readonly class MyEventListener
{
    public function __invoke(ModifyImageSourceCollectionEvent $event): void
    {
        $event->setSourceCollection(
            '<source src="bar-file.jpg" media="(max-device-width: 600px)">',
        );
    }
}
Copied!

New in version 13.0

API

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

Listeners are able to enrich the final source collection result

setSourceCollection ( string $sourceCollection)
param $sourceCollection

the sourceCollection

getSourceCollection ( )
Returns
string
getFullSourceCollection ( )
Returns
string
getSourceConfiguration ( )
Returns
array
getSourceRenderConfiguration ( )
Returns
array
getContentObjectRenderer ( )
Returns
\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer