[BUGFIX] Don't duplicate thumbnails in file list and file selector 99/53399/4
authorTymoteusz Motylewski <t.motylewski@gmail.com>
Tue, 4 Jul 2017 20:03:27 +0000 (22:03 +0200)
committerGeorg Ringer <georg.ringer@gmail.com>
Sat, 15 Jul 2017 06:53:46 +0000 (08:53 +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/53399
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Frans Saris <franssaris@gmail.com>
Tested-by: Frans Saris <franssaris@gmail.com>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
typo3/sysext/core/Classes/Resource/OnlineMedia/Processing/PreviewProcessing.php
typo3/sysext/core/Classes/Resource/ProcessedFile.php

index 2be936c..3e760e2 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 ProcessedFile::CONTEXT_IMAGEPREVIEW:
-                // 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 617bd75..73d1e8f 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);