‪TYPO3CMS  9.5
TYPO3\CMS\Core\Resource\Processing\LocalPreviewHelper Class Reference

Public Member Functions

 __construct (LocalImageProcessor $processor)
 
array null process (TaskInterface $task)
 

Static Public Member Functions

static array preProcessConfiguration (array $configuration)
 

Protected Member Functions

string getTemporaryFilePath (TaskInterface $task)
 
array generatePreviewFromFile (File $file, array $configuration, $targetFilePath)
 

Protected Attributes

LocalImageProcessor $processor
 

Static Protected Attributes

static array $defaultConfiguration
 

Detailed Description

Helper for creating local image previews using TYPO3s image processing classes.

Definition at line 28 of file LocalPreviewHelper.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Core\Resource\Processing\LocalPreviewHelper::__construct ( LocalImageProcessor  $processor)

Member Function Documentation

◆ generatePreviewFromFile()

◆ getTemporaryFilePath()

string TYPO3\CMS\Core\Resource\Processing\LocalPreviewHelper::getTemporaryFilePath ( TaskInterface  $task)
protected

Returns the path to a temporary file for processing

Parameters
TaskInterface$task
Returns
‪string

Definition at line 105 of file LocalPreviewHelper.php.

References TYPO3\CMS\Core\Resource\Processing\TaskInterface\getTargetFileExtension().

Referenced by TYPO3\CMS\Core\Resource\Processing\LocalPreviewHelper\process().

◆ preProcessConfiguration()

static array TYPO3\CMS\Core\Resource\Processing\LocalPreviewHelper::preProcessConfiguration ( array  $configuration)
static

Enforce default configuration for preview processing

Parameters
array$configuration
Returns
‪array

Definition at line 57 of file LocalPreviewHelper.php.

References TYPO3\CMS\Core\Utility\MathUtility\forceIntegerInRange().

Referenced by TYPO3\CMS\Core\Resource\Service\FileProcessingService\processFile().

◆ process()

array null TYPO3\CMS\Core\Resource\Processing\LocalPreviewHelper::process ( TaskInterface  $task)

This method actually does the processing of files locally

takes the original file (on remote storages this will be fetched from the remote server) does the IM magic on the local server by creating a temporary typo3temp/ file copies the typo3temp/ file to the processing folder of the target storage removes the typo3temp/ file

The returned array has the following structure: width => 100 height => 200 filePath => /some/path

If filePath isn't set but width and height are the original file is used as ProcessedFile with the returned width and height. This is for example useful for SVG images.

Parameters
TaskInterface$task
Returns
‪array|null

Definition at line 84 of file LocalPreviewHelper.php.

References TYPO3\CMS\Core\Resource\Processing\LocalPreviewHelper\generatePreviewFromFile(), TYPO3\CMS\Core\Resource\Processing\TaskInterface\getConfiguration(), TYPO3\CMS\Core\Resource\Processing\TaskInterface\getSourceFile(), and TYPO3\CMS\Core\Resource\Processing\LocalPreviewHelper\getTemporaryFilePath().

Member Data Documentation

◆ $defaultConfiguration

array TYPO3\CMS\Core\Resource\Processing\LocalPreviewHelper::$defaultConfiguration
staticprotected
Initial value:
= array(
'width' => 64,
'height' => 64,
)

Default preview configuration

Definition at line 34 of file LocalPreviewHelper.php.

◆ $processor

LocalImageProcessor TYPO3\CMS\Core\Resource\Processing\LocalPreviewHelper::$processor
protected