IsFileSelectableEvent
New in version 12.1
The PSR-14 event \TYPO3\
allows to decide whether a file can be selected in the file browser.
To get the image dimensions (width and height) of a file, you can retrieve the
file and use the get
method.
Example
Registration of the event listener in the extension's Services.
:
services:
# Place here the default dependency injection configuration
MyVendor\MyExtension\Backend\EventListener\MyEventListener:
tags:
- name: event.listener
identifier: 'my-extension/backend/modify-file-is-selectable'
Read how to configure dependency injection in extensions.
The corresponding event listener class:
<?php
declare(strict_types=1);
namespace MyVendor\MyExtension\Backend\EventListener;
use TYPO3\CMS\Backend\ElementBrowser\Event\IsFileSelectableEvent;
final class MyEventListener
{
public function __invoke(IsFileSelectableEvent $event): void
{
// Deny selection of "png" images
if ($event->getFile()->getExtension() === 'png') {
$event->denyFileSelection();
}
}
}