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

Public Member Functions

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

Static Public Member Functions

static 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

Generates a preview for a local file

Parameters
string$originalFileName‪Optional input file path
array$configurationProcessing configuration
string$targetFilePath‪Output file path
Returns
‪array

Definition at line 150 of file LocalPreviewHelper.php.

Referenced by TYPO3\CMS\Core\Resource\Processing\LocalPreviewHelper\generatePreviewFromFile(), and TYPO3\CMS\Core\Resource\Processing\LocalPreviewHelper\processWithLocalFile().

◆ getTemporaryFilePath()

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

Returns the path to a temporary file for processing

Returns
‪non-empty-string

Definition at line 109 of file LocalPreviewHelper.php.

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

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

◆ preProcessConfiguration()

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

Enforce default configuration for preview processing

Todo:
‪This method is not needed anymore and will be deprecated (once the whole class can be removed)

Definition at line 45 of file LocalPreviewHelper.php.

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

◆ 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(), TYPO3\CMS\Core\Resource\Processing\LocalPreviewHelper\getTemporaryFilePath(), and TYPO3\CMS\Core\Resource\Processing\TaskInterface\sanitizeConfiguration().

◆ processWithLocalFile()

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

Definition at line 99 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:
= [
'width' => 64,
'height' => 64,
]

Default preview configuration

Todo:
‪once preProcessConfiguration() is not needed anymore (or the whole class), this property can be removed

Definition at line 35 of file LocalPreviewHelper.php.