Custom file processors 

For custom needs in terms of file processing, registration of custom file processors is available.

Create a new processor class 

The file must implement the \TYPO3\CMS\Core\Resource\Processing\ProcessorInterface and two required methods.

canProcessTask()
Will decide whether the given file should be handled at all. The expected return type is boolean.
processTask()
Will then do whatever needs to be done to process the given file.

Register the file processor 

To register a new processor, add the following code to ext_localconf.php

EXT:my_extension/ext_localconf.php
<?php

$GLOBALS['TYPO3_CONF_VARS']['SYS']['fal']['processors']['MyNewImageProcessor'] = [
  'className' => \MyVendor\MyExtension\Resource\Processing\MyNewImageProcessor::class,
  'before' => ['LocalImageProcessor'],
];
Copied!

With the before and after options, priority can be defined.

Processing system resources from EXT: and PKG: 

Changed in version 15.0 Breaking: #110702 - Widened FAL processing task interfaces

The processing pipeline also processes system resources. Before, an image from an extension was processed through a FAL compatibility storage.

The processing pipeline also scales and crops images that an extension or a package ships, referenced as EXT: or PKG: system resource. For such a task TaskInterface::getSourceFile() returns a SystemResourceInterface that is not a FAL File . The result is not stored in the database or in a _processed_/ folder. See Processed files.

A processor receives such a task only if it implements the marker interface ResourceAwareProcessorInterface . The Core processors LocalImageProcessor and SvgImageProcessor implement it for the task type Image.CropScaleMask. A subclass of these processors inherits the interface. If the subclass uses methods that only a FAL file has, it must decline other sources in canProcessTask() .

Example: Process only FAL files in a subclass of LocalImageProcessor 

The processor declines a task if the source is not a FAL file. The Core processors then handle the system resources.

EXT:my_extension/Classes/Resource/Processing/FalOnlyImageProcessor.php
<?php

declare(strict_types=1);

namespace MyVendor\MyExtension\Resource\Processing;

use TYPO3\CMS\Core\Resource\File;
use TYPO3\CMS\Core\Resource\Processing\LocalImageProcessor;
use TYPO3\CMS\Core\Resource\Processing\TaskInterface;

class FalOnlyImageProcessor extends LocalImageProcessor
{
  public function canProcessTask(TaskInterface $task): bool
  {
    // Leave system resources from EXT: and PKG: to the Core processors
    return $task->getSourceFile() instanceof File
        && parent::canProcessTask($task);
  }
}
Copied!