diff --git a/typo3/sysext/core/Configuration/DefaultConfiguration.php b/typo3/sysext/core/Configuration/DefaultConfiguration.php index 4f5ee07db892007715df9cba48cdf24d193a8b58..e889afebc7bcb7b60d538e9d0fcb445580785a79 100644 --- a/typo3/sysext/core/Configuration/DefaultConfiguration.php +++ b/typo3/sysext/core/Configuration/DefaultConfiguration.php @@ -859,6 +859,10 @@ return [ options.file_list.enableDisplayBigControlPanel=selectable options.file_list.enableDisplayThumbnails=selectable options.file_list.enableClipBoard=selectable + options.file_list.thumbnail { + width = 64 + height = 64 + } options.pageTree { doktypesToShowInNewPageDragArea = 1,6,4,7,3,254,255,199 } diff --git a/typo3/sysext/core/Documentation/Changelog/master/Feature-73357-MakeThumbnailSizeInFileBrowserConfigurable.rst b/typo3/sysext/core/Documentation/Changelog/master/Feature-73357-MakeThumbnailSizeInFileBrowserConfigurable.rst new file mode 100644 index 0000000000000000000000000000000000000000..c0a806b03fc43a3533d5af34c90ac14da56251dd --- /dev/null +++ b/typo3/sysext/core/Documentation/Changelog/master/Feature-73357-MakeThumbnailSizeInFileBrowserConfigurable.rst @@ -0,0 +1,26 @@ +.. include:: ../../Includes.txt + +================================================================== +Feature: #73357 - Make thumbnail size in file browser configurable +================================================================== + +See :issue:`73357` + +Description +=========== + +The default size of thumbnails in the file list is 64x64. These values can now be configured with UserTSConfig. + +Example: + +.. code-block:: typoscript + options.file_list.thumbnail.width = 256 + options.file_list.thumbnail.height = 256 + + +Impact +====== + +All preview images in the file list will be rendered in the configured thumbnail size. + +.. index:: Backend, TSConfig diff --git a/typo3/sysext/filelist/Classes/Configuration/ThumbnailConfiguration.php b/typo3/sysext/filelist/Classes/Configuration/ThumbnailConfiguration.php new file mode 100644 index 0000000000000000000000000000000000000000..88441b02468c2dfa9a8352f6cf3e54a82836a9ba --- /dev/null +++ b/typo3/sysext/filelist/Classes/Configuration/ThumbnailConfiguration.php @@ -0,0 +1,68 @@ +<?php +declare(strict_types=1); + +namespace TYPO3\CMS\Filelist\Configuration; + +/* + * This file is part of the TYPO3 CMS project. + * + * It is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License, either version 2 + * of the License, or any later version. + * + * For the full copyright and license information, please read the + * LICENSE.txt file that was distributed with this source code. + * + * The TYPO3 project - inspiring people to share! + */ + +use TYPO3\CMS\Backend\Utility\BackendUtility; +use TYPO3\CMS\Core\SingletonInterface; +use TYPO3\CMS\Core\Utility\MathUtility; + +/** + * Class TYPO3\CMS\Filelist\Configuration\ThumbnailConfiguration + */ +class ThumbnailConfiguration implements SingletonInterface +{ + /** + * @var int + */ + protected $width = 64; + + /** + * @var int + */ + protected $height = 64; + + public function __construct() + { + $modTSconfig = BackendUtility::getModTSconfig(0, 'options.file_list'); + if (isset($modTSconfig['properties']['thumbnail.']['width']) + && MathUtility::canBeInterpretedAsInteger($modTSconfig['properties']['thumbnail.']['width']) + ) { + $this->width = (int)$modTSconfig['properties']['thumbnail.']['width']; + } + if (isset($modTSconfig['properties']['thumbnail.']['height']) + && MathUtility::canBeInterpretedAsInteger($modTSconfig['properties']['thumbnail.']['height']) + ) { + $this->height = (int)$modTSconfig['properties']['thumbnail.']['height']; + } + } + + /** + * @return int + */ + public function getWidth(): int + { + return $this->width; + } + + /** + * @return int + */ + public function getHeight(): int + { + return $this->height; + } +} diff --git a/typo3/sysext/filelist/Classes/Controller/FileListController.php b/typo3/sysext/filelist/Classes/Controller/FileListController.php index a97669c494cb88eef8f8b4709b926f95491fea4a..3956199ad97f9e43c79053277571d2b49976e016 100644 --- a/typo3/sysext/filelist/Classes/Controller/FileListController.php +++ b/typo3/sysext/filelist/Classes/Controller/FileListController.php @@ -34,6 +34,7 @@ use TYPO3\CMS\Core\Utility\MathUtility; use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; use TYPO3\CMS\Extbase\Mvc\View\ViewInterface; use TYPO3\CMS\Extbase\Utility\LocalizationUtility; +use TYPO3\CMS\Filelist\Configuration\ThumbnailConfiguration; use TYPO3\CMS\Filelist\FileList; /** @@ -519,6 +520,12 @@ class FileListController extends ActionController $pageRenderer = $this->view->getModuleTemplate()->getPageRenderer(); $pageRenderer->loadRequireJsModule('TYPO3/CMS/Filelist/FileList'); + $thumbnailConfiguration = GeneralUtility::makeInstance(ThumbnailConfiguration::class); + $this->view->assign('thumbnail', [ + 'width' => $thumbnailConfiguration->getWidth(), + 'height' => $thumbnailConfiguration->getHeight(), + ]); + $this->view->assign('searchWord', $searchWord); $this->view->assign('files', $fileFacades); $this->view->assign('deleteUrl', BackendUtility::getModuleUrl('tce_file')); diff --git a/typo3/sysext/filelist/Classes/FileList.php b/typo3/sysext/filelist/Classes/FileList.php index 207bd6b3be774c8d70642b4d8c48aa55aec81333..a07af92a93b30070c90475b45880770d532cab4d 100644 --- a/typo3/sysext/filelist/Classes/FileList.php +++ b/typo3/sysext/filelist/Classes/FileList.php @@ -36,6 +36,7 @@ use TYPO3\CMS\Core\Resource\Utility\ListUtility; use TYPO3\CMS\Core\Type\Bitmask\JsConfirmation; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\MathUtility; +use TYPO3\CMS\Filelist\Configuration\ThumbnailConfiguration; use TYPO3\CMS\Filelist\Controller\FileListController; /** @@ -266,6 +267,11 @@ class FileList */ protected $fileListController; + /** + * @var ThumbnailConfiguration + */ + protected $thumbnailConfiguration; + /** * Construct * @@ -281,6 +287,7 @@ class FileList $this->determineScriptUrl(); $this->fileListController = $fileListController; $this->iconFactory = GeneralUtility::makeInstance(IconFactory::class); + $this->thumbnailConfiguration = GeneralUtility::makeInstance(ThumbnailConfiguration::class); $modTSconfig = BackendUtility::getModTSconfig(0, 'options.file_list'); if (!empty($modTSconfig['properties']['filesPerPage'])) { @@ -1099,7 +1106,13 @@ class FileList . '</span>'; // Thumbnails? } elseif ($this->thumbs && ($this->isImage($ext) || $this->isMediaFile($ext))) { - $processedFile = $fileObject->process(ProcessedFile::CONTEXT_IMAGEPREVIEW, []); + $processedFile = $fileObject->process( + ProcessedFile::CONTEXT_IMAGEPREVIEW, + [ + 'width' => $this->thumbnailConfiguration->getWidth(), + 'height' => $this->thumbnailConfiguration->getHeight() + ] + ); if ($processedFile) { $thumbUrl = $processedFile->getPublicUrl(true); $theData[$field] .= '<br /><img src="' . $thumbUrl . '" ' . diff --git a/typo3/sysext/filelist/Resources/Private/Templates/FileList/Search.html b/typo3/sysext/filelist/Resources/Private/Templates/FileList/Search.html index 48531d650325b0d04e5284d08615178af60c36fc..cc2cce93dbdc40d54f50c536988494bc780dc5d8 100644 --- a/typo3/sysext/filelist/Resources/Private/Templates/FileList/Search.html +++ b/typo3/sysext/filelist/Resources/Private/Templates/FileList/Search.html @@ -54,7 +54,7 @@ </f:if> <f:if condition="{file.isImage}"> <br> - <f:image image="{file.resource}" maxWidth="64" maxHeight="43" /> + <f:image image="{file.resource}" maxWidth="{thumbnail.width}" maxHeight="{thumbnail.height}" /> </f:if> </td> <td class="col-control nowrap"> diff --git a/typo3/sysext/recordlist/Classes/Browser/FileBrowser.php b/typo3/sysext/recordlist/Classes/Browser/FileBrowser.php index c93b61011ba74e64f7f72b0cc661cee90755241f..77437ecbfe1cf397eb8de33558516261e2707252 100644 --- a/typo3/sysext/recordlist/Classes/Browser/FileBrowser.php +++ b/typo3/sysext/recordlist/Classes/Browser/FileBrowser.php @@ -26,6 +26,7 @@ use TYPO3\CMS\Core\Resource\Folder; use TYPO3\CMS\Core\Resource\ProcessedFile; use TYPO3\CMS\Core\Resource\ResourceFactory; use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Core\Utility\MathUtility; use TYPO3\CMS\Recordlist\Tree\View\LinkParameterProviderInterface; use TYPO3\CMS\Recordlist\View\FolderUtilityRenderer; @@ -66,6 +67,11 @@ class FileBrowser extends AbstractElementBrowser implements ElementBrowserInterf */ protected $fileRepository; + /** + * @var array + */ + protected $thumbnailConfiguration = []; + /** * Loads additional JavaScript */ @@ -74,6 +80,18 @@ class FileBrowser extends AbstractElementBrowser implements ElementBrowserInterf parent::initialize(); $this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Recordlist/BrowseFiles'); $this->fileRepository = GeneralUtility::makeInstance(FileRepository::class); + + $modTSconfig = BackendUtility::getModTSconfig(0, 'options.file_list'); + if (isset($modTSconfig['properties']['thumbnail.']['width']) + && MathUtility::canBeInterpretedAsInteger($modTSconfig['properties']['thumbnail.']['width']) + ) { + $this->thumbnailConfiguration['width'] = (int)$modTSconfig['properties']['thumbnail.']['width']; + } + if (isset($modTSconfig['properties']['thumbnail.']['height']) + && MathUtility::canBeInterpretedAsInteger($modTSconfig['properties']['thumbnail.']['height']) + ) { + $this->thumbnailConfiguration['height'] = (int)$modTSconfig['properties']['thumbnail.']['height']; + } } /** @@ -270,7 +288,7 @@ class FileBrowser extends AbstractElementBrowser implements ElementBrowserInterf if (!$noThumbs && GeneralUtility::inList(strtolower($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'] . ',' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['mediafile_ext']), strtolower($fileExtension))) { $processedFile = $fileObject->process( ProcessedFile::CONTEXT_IMAGEPREVIEW, - ['width' => 64, 'height' => 64] + $this->thumbnailConfiguration ); $imageUrl = $processedFile->getPublicUrl(true); $imgInfo = [