[TASK] Prevent thumbnail generation for non image files 11/53111/2
authormaikh <typo3@hagenbruch.info>
Sat, 3 Jun 2017 21:33:01 +0000 (23:33 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sun, 4 Jun 2017 09:23:10 +0000 (11:23 +0200)
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/53111
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/backend/Classes/Form/Container/InlineRecordContainer.php
typo3/sysext/backend/Classes/Utility/BackendUtility.php

index 6e5b9ed..47d111f 100644 (file)
@@ -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 = '';
                     }
                 }
             }
index 45c917d..cefc923 100644 (file)
@@ -1695,7 +1695,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()
                     )
                 ) {