ModifyImageSourceCollectionEvent

New in version 13.0: This event serves as a drop-in replacement for the removed hook $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['getImageSourceCollection'].

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 class MyEventListener
{
    public function __invoke(ModifyImageSourceCollectionEvent $event): void
    {
        $event->setSourceCollection(
            '<source src="bar-file.jpg" media="(max-device-width: 600px)">'
        );
    }
}

New in version 13.0: The PHP attribute \TYPO3\CMS\Core\Attribute\AsEventListener has been introduced to tag a PHP class as an event listener. Alternatively, you can also register an event listener via the Configuration/Services.yaml file. Have a look into the section Implementing an event listener in your extension.

API

class TYPO3\CMS\Frontend\ContentObject\Event\ModifyImageSourceCollectionEvent

Listeners are able to enrich the final source collection result

setSourceCollection(string $sourceCollection)
Parameters
  • $sourceCollection (string) -- the sourceCollection

getSourceCollection()
Return type

string

getFullSourceCollection()
Return type

string

getSourceConfiguration()
Return type

array

getSourceRenderConfiguration()
Return type

array

getContentObjectRenderer()
Return type

TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer