diff --git a/typo3/sysext/core/Classes/Resource/File.php b/typo3/sysext/core/Classes/Resource/File.php index 153a94ee3b6c016913b2e80d862697db9f13b404..a3560f5a25d888cb1f614ef8815cb28d14aabbc7 100644 --- a/typo3/sysext/core/Classes/Resource/File.php +++ b/typo3/sysext/core/Classes/Resource/File.php @@ -15,7 +15,6 @@ namespace TYPO3\CMS\Core\Resource; */ use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Core\Utility\MathUtility; /** * File representation in the file abstraction layer. @@ -302,11 +301,6 @@ class File extends AbstractFile */ public function process($taskType, array $configuration) { - if ($taskType === ProcessedFile::CONTEXT_IMAGEPREVIEW) { - $configuration = array_merge(['width' => 64, 'height' => 64], $configuration); - $configuration['width'] = MathUtility::forceIntegerInRange($configuration['width'], 1, 1000); - $configuration['height'] = MathUtility::forceIntegerInRange($configuration['height'], 1, 1000); - } return $this->getStorage()->processFile($this, $taskType, $configuration); } diff --git a/typo3/sysext/core/Classes/Resource/Processing/LocalPreviewHelper.php b/typo3/sysext/core/Classes/Resource/Processing/LocalPreviewHelper.php index 03eca60ee87e693328e204cb95c25aef0720277e..ac791a1e673ef404664c199502208c9544023b91 100644 --- a/typo3/sysext/core/Classes/Resource/Processing/LocalPreviewHelper.php +++ b/typo3/sysext/core/Classes/Resource/Processing/LocalPreviewHelper.php @@ -25,6 +25,16 @@ use TYPO3\CMS\Core\Utility\MathUtility; */ class LocalPreviewHelper { + /** + * Default preview configuration + * + * @var array + */ + protected static $defaultConfiguration = [ + 'width' => 64, + 'height' => 64, + ]; + /** * @var LocalImageProcessor */ @@ -38,6 +48,20 @@ class LocalPreviewHelper $this->processor = $processor; } + /** + * Enforce default configuration for preview processing + * + * @param array $configuration + * @return array + */ + public static function preProcessConfiguration(array $configuration) + { + $configuration = array_replace(static::$defaultConfiguration, $configuration); + $configuration['width'] = MathUtility::forceIntegerInRange($configuration['width'], 1, 1000); + $configuration['height'] = MathUtility::forceIntegerInRange($configuration['height'], 1, 1000); + return $configuration; + } + /** * This method actually does the processing of files locally * @@ -60,11 +84,7 @@ class LocalPreviewHelper public function process(TaskInterface $task) { $sourceFile = $task->getSourceFile(); - - // Merge custom configuration with default configuration - $configuration = array_merge(['width' => 64, 'height' => 64], $task->getConfiguration()); - $configuration['width'] = MathUtility::forceIntegerInRange($configuration['width'], 1); - $configuration['height'] = MathUtility::forceIntegerInRange($configuration['height'], 1); + $configuration = static::preProcessConfiguration($task->getConfiguration()); // Do not scale up if the source file has a size and the target size is larger if ($sourceFile->getProperty('width') > 0 && $sourceFile->getProperty('height') > 0 diff --git a/typo3/sysext/core/Classes/Resource/Service/FileProcessingService.php b/typo3/sysext/core/Classes/Resource/Service/FileProcessingService.php index fbabc89fb75ae1b50ea415b8b83da1bb098250d6..57f0e57978af3d10120a8c4fc7400d78741cb211 100644 --- a/typo3/sysext/core/Classes/Resource/Service/FileProcessingService.php +++ b/typo3/sysext/core/Classes/Resource/Service/FileProcessingService.php @@ -74,6 +74,13 @@ class FileProcessingService */ public function processFile(Resource\FileInterface $fileObject, Resource\ResourceStorage $targetStorage, $taskType, $configuration) { + // Enforce default configuration for preview processing here, + // to be sure we find already processed files below, + // which we wouldn't if we would change the configuration later, as configuration is part of the lookup. + if ($taskType === Resource\ProcessedFile::CONTEXT_IMAGEPREVIEW) { + $configuration = Resource\Processing\LocalPreviewHelper::preProcessConfiguration($configuration); + } + /** @var $processedFileRepository Resource\ProcessedFileRepository */ $processedFileRepository = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Resource\ProcessedFileRepository::class);