[FEATURE] Make thumbnail size in file list configurable
[Packages/TYPO3.CMS.git] / typo3 / sysext / filelist / Classes / Configuration / ThumbnailConfiguration.php
1 <?php
2 declare(strict_types=1);
3
4 namespace TYPO3\CMS\Filelist\Configuration;
5
6 /*
7 * This file is part of the TYPO3 CMS project.
8 *
9 * It is free software; you can redistribute it and/or modify it under
10 * the terms of the GNU General Public License, either version 2
11 * of the License, or any later version.
12 *
13 * For the full copyright and license information, please read the
14 * LICENSE.txt file that was distributed with this source code.
15 *
16 * The TYPO3 project - inspiring people to share!
17 */
18
19 use TYPO3\CMS\Backend\Utility\BackendUtility;
20 use TYPO3\CMS\Core\SingletonInterface;
21 use TYPO3\CMS\Core\Utility\MathUtility;
22
23 /**
24 * Class TYPO3\CMS\Filelist\Configuration\ThumbnailConfiguration
25 */
26 class ThumbnailConfiguration implements SingletonInterface
27 {
28 /**
29 * @var int
30 */
31 protected $width = 64;
32
33 /**
34 * @var int
35 */
36 protected $height = 64;
37
38 public function __construct()
39 {
40 $modTSconfig = BackendUtility::getModTSconfig(0, 'options.file_list');
41 if (isset($modTSconfig['properties']['thumbnail.']['width'])
42 && MathUtility::canBeInterpretedAsInteger($modTSconfig['properties']['thumbnail.']['width'])
43 ) {
44 $this->width = (int)$modTSconfig['properties']['thumbnail.']['width'];
45 }
46 if (isset($modTSconfig['properties']['thumbnail.']['height'])
47 && MathUtility::canBeInterpretedAsInteger($modTSconfig['properties']['thumbnail.']['height'])
48 ) {
49 $this->height = (int)$modTSconfig['properties']['thumbnail.']['height'];
50 }
51 }
52
53 /**
54 * @return int
55 */
56 public function getWidth(): int
57 {
58 return $this->width;
59 }
60
61 /**
62 * @return int
63 */
64 public function getHeight(): int
65 {
66 return $this->height;
67 }
68 }