LocalPreviewHelper

class \TYPO3\CMS\Core\Resource\Processing\LocalPreviewHelper

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

Table of Contents

Properties

$defaultConfiguration  : array
Default preview configuration

Methods

preProcessConfiguration()  : array
Enforce default configuration for preview processing
process()  : array|null
This method actually does the processing of files locally
processWithLocalFile()  : array|null
Does the heavy lifting prescribed in processTask() except that the processing can be performed on any given local image
generatePreviewFromFile()  : array
Generates a preview for a file
generatePreviewFromLocalFile()  : array
Generates a preview for a local file
getTemporaryFilePath()  : non-empty-string
Returns the path to a temporary file for processing

Properties

$defaultConfiguration

Default preview configuration

protected static array $defaultConfiguration = ['width' => 64, 'height' => 64]

Tags

todo

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

Methods

preProcessConfiguration()

Enforce default configuration for preview processing

public static preProcessConfiguration(array $configuration) : array

Parameters

$configuration : array

Tags

todo

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

Return values

array

process()

This method actually does the processing of files locally

public process(TaskInterface $task) : array|null

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

$task : TaskInterface

Return values

array|null

processWithLocalFile()

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

public processWithLocalFile(TaskInterface $task, string $localFile) : array|null

Parameters

$task : TaskInterface
$localFile : string

Return values

array|null

generatePreviewFromFile()

Generates a preview for a file

protected generatePreviewFromFile(File $file, array $configuration, string $targetFilePath) : array

Parameters

$file : File

The source file

$configuration : array

Processing configuration

$targetFilePath : string

Output file path

Return values

array

generatePreviewFromLocalFile()

Generates a preview for a local file

protected generatePreviewFromLocalFile(string $originalFileName, array $configuration, string $targetFilePath) : array

Parameters

$originalFileName : string

Optional input file path

$configuration : array

Processing configuration

$targetFilePath : string

Output file path

Return values

array

getTemporaryFilePath()

Returns the path to a temporary file for processing

protected getTemporaryFilePath(TaskInterface $task) : non-empty-string

Parameters

$task : TaskInterface

Return values

non-empty-string
On this page