From 675852a229956a5c5523479df4812ab385e7f884 Mon Sep 17 00:00:00 2001 From: maikh <typo3@hagenbruch.info> Date: Sat, 3 Jun 2017 23:33:01 +0200 Subject: [PATCH] [TASK] Prevent thumbnail generation for non image files Check files if they are image files before thumbnail generation. Change-Id: I7dae2ccbb5ab93e582d21efe8f7d29cf7006a1c3 Resolves: #81147 Releases: master, 8.7 Reviewed-on: https://review.typo3.org/53107 Reviewed-by: Jo Hasenau <info@cybercraft.de> Tested-by: Jo Hasenau <info@cybercraft.de> Tested-by: TYPO3com <no-reply@typo3.com> Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch> Tested-by: Christian Kuhn <lolli@schwarzbu.ch> --- .../Form/Container/InlineRecordContainer.php | 24 ++++++++++++------- .../Classes/Utility/BackendUtility.php | 2 +- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/typo3/sysext/backend/Classes/Form/Container/InlineRecordContainer.php b/typo3/sysext/backend/Classes/Form/Container/InlineRecordContainer.php index 415ca2c1ad76..095f1ec9a7fc 100644 --- a/typo3/sysext/backend/Classes/Form/Container/InlineRecordContainer.php +++ b/typo3/sysext/backend/Classes/Form/Container/InlineRecordContainer.php @@ -340,15 +340,21 @@ class InlineRecordContainer extends AbstractContainer $imageSetup['crop'] = $rec['crop']; } $imageSetup = array_merge(['width' => '45', 'height' => '45c'], $imageSetup); - $processedImage = $fileObject->process(ProcessedFile::CONTEXT_IMAGEPREVIEW, $imageSetup); - // Only use a thumbnail if the processing process was successful by checking if image width is set - if ($processedImage->getProperty('width')) { - $imageUrl = $processedImage->getPublicUrl(true); - $thumbnail = '<img src="' . $imageUrl . '" ' . - 'width="' . $processedImage->getProperty('width') . '" ' . - 'height="' . $processedImage->getProperty('height') . '" ' . - 'alt="' . htmlspecialchars($altText) . '" ' . - 'title="' . htmlspecialchars($altText) . '">'; + + if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['thumbnails'] + && GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], $fileObject->getProperty('extension'))) { + $processedImage = $fileObject->process(ProcessedFile::CONTEXT_IMAGEPREVIEW, $imageSetup); + // Only use a thumbnail if the processing process was successful by checking if image width is set + if ($processedImage->getProperty('width')) { + $imageUrl = $processedImage->getPublicUrl(true); + $thumbnail = '<img src="' . $imageUrl . '" ' . + 'width="' . $processedImage->getProperty('width') . '" ' . + 'height="' . $processedImage->getProperty('height') . '" ' . + 'alt="' . htmlspecialchars($altText) . '" ' . + 'title="' . htmlspecialchars($altText) . '">'; + } + } else { + $thumbnail = ''; } } } diff --git a/typo3/sysext/backend/Classes/Utility/BackendUtility.php b/typo3/sysext/backend/Classes/Utility/BackendUtility.php index e153658dbd19..99e90d87f894 100644 --- a/typo3/sysext/backend/Classes/Utility/BackendUtility.php +++ b/typo3/sysext/backend/Classes/Utility/BackendUtility.php @@ -1286,7 +1286,7 @@ class BackendUtility // Preview web image or media elements if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['thumbnails'] && GeneralUtility::inList( - $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'] . ',' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['mediafile_ext'], + $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], $fileReferenceObject->getExtension() ) ) { -- GitLab