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

Public Member Functions

array null process (TaskInterface $task)
 
array null processWithLocalFile (TaskInterface $task, string $localFile)
 

Static Public Member Functions

static array preProcessConfiguration (array $configuration)
 

Protected Member Functions

non empty string getTemporaryFilePath (TaskInterface $task)
 
array generatePreviewFromFile (File $file, array $configuration, string $targetFilePath)
 
array generatePreviewFromLocalFile (string $originalFileName, array $configuration, string $targetFilePath)
 

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.

Member Function Documentation

◆ generatePreviewFromFile()

array TYPO3\CMS\Core\Resource\Processing\LocalPreviewHelper::generatePreviewFromFile ( File  $file,
array  $configuration,
string  $targetFilePath 
)
protected

◆ generatePreviewFromLocalFile()

array TYPO3\CMS\Core\Resource\Processing\LocalPreviewHelper::generatePreviewFromLocalFile ( string  $originalFileName,
array  $configuration,
string  $targetFilePath 
)
protected

◆ getTemporaryFilePath()

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

Returns the path to a temporary file for processing

Parameters
TaskInterface$task
Returns
‪non-empty-string

Definition at line 113 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 45 of file LocalPreviewHelper.php.

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

Referenced by TYPO3\CMS\Core\Imaging\ImageDimension\getConfigurationForImageCropScaleMask(), and 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 79 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().

◆ processWithLocalFile()

array null TYPO3\CMS\Core\Resource\Processing\LocalPreviewHelper::processWithLocalFile ( TaskInterface  $task,
string  $localFile 
)

Does the heavy lifting prescribed in processTask() except that the processing can be performed on any given local image

Parameters
TaskInterface$task
string$localFile
Returns
‪array|null

Definition at line 102 of file LocalPreviewHelper.php.

References TYPO3\CMS\Core\Resource\Processing\LocalPreviewHelper\generatePreviewFromLocalFile(), and TYPO3\CMS\Core\Resource\Processing\TaskInterface\getConfiguration().

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.