Skip to content
Snippets Groups Projects
Commit 675852a2 authored by maikh's avatar maikh Committed by Christian Kuhn
Browse files

[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: default avatarJo Hasenau <info@cybercraft.de>
Tested-by: default avatarJo Hasenau <info@cybercraft.de>
Tested-by: default avatarTYPO3com <no-reply@typo3.com>
Reviewed-by: default avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: default avatarChristian Kuhn <lolli@schwarzbu.ch>
parent 55a45ee6
Branches
Tags
No related merge requests found
......@@ -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 = '';
}
}
}
......
......@@ -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()
)
) {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment