IsFileSelectableEvent

New in version 12.1.

The PSR-14 event \TYPO3\CMS\Backend\ElementBrowser\Event\IsFileSelectableEvent 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 getProperty() method.

Example

Registration of the event in your extension's Services.yaml:

MyVendor\MyPackage\Backend\MyEventListener:
  tags
    - name: event.listener
      identifier: 'my-package/backend/modify-file-is-selectable'

The corresponding event listener class:

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();
        }
    }
}

API

class TYPO3\CMS\Backend\ElementBrowser\Event\IsFileSelectableEvent

Listeners to this event are able to define whether a file can be selected in the file browser

getFile()
Return type

TYPO3\CMS\Core\Resource\FileInterface

isFileSelectable()
Return type

bool

allowFileSelection()
denyFileSelection()