[BUGFIX] Don't duplicate thumbnails in file list and file selector 08/53508/2
authorTymoteusz Motylewski <t.motylewski@gmail.com>
Tue, 4 Jul 2017 20:03:27 +0000 (22:03 +0200)
committerTymoteusz Motylewski <t.motylewski@gmail.com>
Sat, 15 Jul 2017 08:38:26 +0000 (10:38 +0200)
Default width and height for thumbnails is now applied in ProcessedFile
thus configuration column of the sys_file_processedfile table is filled
even if empty configuration was passed to File->Process().

This prevents thumbnails with the same content but different names being
generated, thus improves performance.

Resolves: #81776
Releases: master, 8.7, 7.6
Change-Id: Ie001e3d6404b52c251d9ed24bcac461ed75050b8
Reviewed-on: https://review.typo3.org/53508
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Tymoteusz Motylewski <t.motylewski@gmail.com>
Tested-by: Tymoteusz Motylewski <t.motylewski@gmail.com>
typo3/sysext/core/Classes/Resource/OnlineMedia/Processing/PreviewProcessing.php
typo3/sysext/core/Classes/Resource/ProcessedFile.php

index d89ff7f..65d1c83 100644 (file)
@@ -24,7 +24,6 @@ use TYPO3\CMS\Core\Resource\Processing\LocalImageProcessor;
 use TYPO3\CMS\Core\Resource\Service\FileProcessingService;
 use TYPO3\CMS\Core\Utility\CommandUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Core\Utility\MathUtility;
 use TYPO3\CMS\Frontend\Imaging\GifBuilder;
 
 /**
@@ -79,12 +78,9 @@ class PreviewProcessing
             return;
         }
         $temporaryFileNameForResizedThumb = uniqid(PATH_site . 'typo3temp/var/transient/online_media_' . $file->getHashedIdentifier()) . '.jpg';
+        $configuration = $processedFile->getProcessingConfiguration();
         switch ($taskType) {
             case 'Image.Preview':
-                // Merge custom configuration with default configuration
-                $configuration = array_merge(['width' => 64, 'height' => 64], $configuration);
-                $configuration['width'] = MathUtility::forceIntegerInRange($configuration['width'], 1, 1000);
-                $configuration['height'] = MathUtility::forceIntegerInRange($configuration['height'], 1, 1000);
                 $this->resizeImage($temporaryFileName, $temporaryFileNameForResizedThumb, $configuration);
                 break;
 
index 74d4260..4ab9c7a 100644 (file)
@@ -118,6 +118,11 @@ class ProcessedFile extends AbstractFile
         $this->originalFileSha1 = $this->originalFile->getSha1();
         $this->storage = $originalFile->getStorage()->getProcessingFolder()->getStorage();
         $this->taskType = $taskType;
+        if ($taskType === self::CONTEXT_IMAGEPREVIEW) {
+            $processingConfiguration = array_merge(['width' => 64, 'height' => 64], $processingConfiguration);
+            $processingConfiguration['width'] = MathUtility::forceIntegerInRange($processingConfiguration['width'], 1, 1000);
+            $processingConfiguration['height'] = MathUtility::forceIntegerInRange($processingConfiguration['height'], 1, 1000);
+        }
         $this->processingConfiguration = $processingConfiguration;
         if (is_array($databaseRow)) {
             $this->reconstituteFromDatabaseRecord($databaseRow);