‪TYPO3CMS  ‪main
ImageCropScaleMaskTask.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
21 
26 {
27  protected string|null ‪$targetFileExtension;
28 
29  public function ‪getType(): string
30  {
31  return 'Image';
32  }
33 
34  public function ‪getName(): string
35  {
36  return 'CropScaleMask';
37  }
38 
43  public function ‪getTargetFileExtension(): string
44  {
45  if (!isset($this->targetFileExtension)) {
46  $this->targetFileExtension = $this->‪determineTargetFileExtension();
47  }
49  }
50 
56  protected function ‪determineTargetFileExtension(): string
57  {
58  if (!empty($this->configuration['fileExtension'])) {
59  ‪$targetFileExtension = $this->configuration['fileExtension'];
60  } elseif (in_array($this->‪getSourceFile()->getExtension(), ['jpg', 'jpeg', 'png', 'gif', 'svg'], true)) {
61  ‪$targetFileExtension = $this->‪getSourceFile()->getExtension();
62  } elseif ($this->‪getSourceFile()->getExtension() === 'webp' && ‪GeneralUtility::inList(‪$GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'] ?? '', 'webp')) {
63  ‪$targetFileExtension = $this->‪getSourceFile()->getExtension();
64  } else {
65  // Thumbnails from non-processable files will be converted to 'png'
67  }
69  }
70 
71  public function ‪getTargetFileName(): string
72  {
73  return 'csm_'
74  . $this->‪getSourceFile()->getNameWithoutExtension()
75  . '_' . $this->‪getConfigurationChecksum()
76  . '.' . $this->‪getTargetFileExtension();
77  }
78 }
‪TYPO3\CMS\Core\Resource\Processing\AbstractTask\getConfigurationChecksum
‪getConfigurationChecksum()
Definition: AbstractTask.php:58
‪TYPO3\CMS\Core\Resource\Processing\AbstractTask\getSourceFile
‪getSourceFile()
Definition: AbstractTask.php:97
‪TYPO3\CMS\Core\Resource\Processing\ImageCropScaleMaskTask\determineTargetFileExtension
‪determineTargetFileExtension()
Definition: ImageCropScaleMaskTask.php:56
‪TYPO3\CMS\Core\Resource\Processing\ImageCropScaleMaskTask\getTargetFileName
‪getTargetFileName()
Definition: ImageCropScaleMaskTask.php:71
‪TYPO3\CMS\Core\Resource\Processing\ImageCropScaleMaskTask\$targetFileExtension
‪string null $targetFileExtension
Definition: ImageCropScaleMaskTask.php:27
‪TYPO3\CMS\Core\Resource\Processing
Definition: AbstractTask.php:18
‪TYPO3\CMS\Core\Resource\Processing\ImageCropScaleMaskTask\getTargetFileExtension
‪getTargetFileExtension()
Definition: ImageCropScaleMaskTask.php:43
‪TYPO3\CMS\Core\Resource\Processing\ImageCropScaleMaskTask
Definition: ImageCropScaleMaskTask.php:26
‪TYPO3\CMS\Core\Resource\Processing\ImageCropScaleMaskTask\getType
‪getType()
Definition: ImageCropScaleMaskTask.php:29
‪TYPO3\CMS\Core\Resource\Processing\ImageCropScaleMaskTask\getName
‪getName()
Definition: ImageCropScaleMaskTask.php:34
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Core\Resource\Processing\AbstractTask
Definition: AbstractTask.php:29
‪TYPO3\CMS\Core\Utility\GeneralUtility\inList
‪static bool inList($list, $item)
Definition: GeneralUtility.php:422
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52