‪TYPO3CMS  10.4
PreviewProcessing.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
23 
28 {
29  public function ‪canProcessTask(‪TaskInterface $task): bool
30  {
31  return $task->‪getType() === 'Image'
32  && in_array($task->‪getName(), ['Preview', 'CropScaleMask'], true)
33  && ($helperRegistry = ‪OnlineMediaHelperRegistry::getInstance())->hasOnlineMediaHelper(($sourceFile = $task->‪getSourceFile())->getExtension())
34  && ($previewImageFile = $helperRegistry->getOnlineMediaHelper($sourceFile)->getPreviewImage($sourceFile))
35  && !empty($previewImageFile)
36  && file_exists($previewImageFile);
37  }
38 
39  public function ‪processTask(‪TaskInterface $task): void
40  {
41  $file = $task->‪getSourceFile();
42  GeneralUtility::makeInstance(LocalImageProcessor::class)
43  ->processTaskWithLocalFile(
44  $task,
46  ->getOnlineMediaHelper($file)
47  ->getPreviewImage($file)
48  );
49  }
50 }
‪TYPO3\CMS\Core\Resource\OnlineMedia\Processing
Definition: PreviewProcessing.php:16
‪TYPO3\CMS\Core\Resource\OnlineMedia\Processing\PreviewProcessing
Definition: PreviewProcessing.php:28
‪TYPO3\CMS\Core\Resource\OnlineMedia\Helpers\OnlineMediaHelperRegistry
Definition: OnlineMediaHelperRegistry.php:27
‪TYPO3\CMS\Core\Resource\Processing\TaskInterface\getType
‪string getType()
‪TYPO3\CMS\Core\Resource\Processing\TaskInterface
Definition: TaskInterface.php:33
‪TYPO3\CMS\Core\Resource\Processing\TaskInterface\getSourceFile
‪Resource File getSourceFile()
‪TYPO3\CMS\Core\Resource\Processing\LocalImageProcessor
Definition: LocalImageProcessor.php:25
‪TYPO3\CMS\Core\Resource\OnlineMedia\Processing\PreviewProcessing\canProcessTask
‪canProcessTask(TaskInterface $task)
Definition: PreviewProcessing.php:29
‪TYPO3\CMS\Core\Resource\Processing\TaskInterface\getName
‪string getName()
‪TYPO3\CMS\Core\Resource\OnlineMedia\Helpers\OnlineMediaHelperRegistry\getInstance
‪static OnlineMediaHelperRegistry getInstance()
Definition: OnlineMediaHelperRegistry.php:33
‪TYPO3\CMS\Core\Resource\OnlineMedia\Processing\PreviewProcessing\processTask
‪processTask(TaskInterface $task)
Definition: PreviewProcessing.php:39
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Core\Resource\Processing\ProcessorInterface
Definition: ProcessorInterface.php:22