From cbe4e5d6b7a7700b433dd18f3ed74d98f365414c Mon Sep 17 00:00:00 2001 From: Christoph Lehmann Date: Wed, 30 Aug 2023 17:07:41 +0200 Subject: [PATCH] [BUGFIX] FileProcessor: File property width might not be set Image and crop relevant file properties are only set, when possible. Resolves: #640 --- Classes/Utility/FileUtility.php | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/Classes/Utility/FileUtility.php b/Classes/Utility/FileUtility.php index 5254397e..96480e0b 100644 --- a/Classes/Utility/FileUtility.php +++ b/Classes/Utility/FileUtility.php @@ -80,7 +80,6 @@ public function processFile( $fileReferenceUid = $fileReference->getUid(); $uidLocal = $fileReference->getProperty('uid_local'); $fileRenderer = $this->rendererRegistry->getRenderer($fileReference); - $crop = $fileReference->getProperty('crop'); $link = $fileReference->getProperty('link'); $linkData = null; @@ -116,19 +115,22 @@ public function processFile( 'uidLocal' => $uidLocal, 'fileReferenceUid' => $fileReferenceUid, 'size' => $this->calculateKilobytesToFileSize((int)$fileReference->getSize()), - 'dimensions' => [ - 'width' => $fileReference->getProperty('width'), - 'height' => $fileReference->getProperty('height'), - ], - 'cropDimensions' => [ - 'width' => $this->getCroppedDimensionalProperty($fileReference, 'width', $cropVariant), - 'height' => $this->getCroppedDimensionalProperty($fileReference, 'height', $cropVariant), - ], - 'crop' => $crop, 'autoplay' => $fileReference->getProperty('autoplay'), 'extension' => $fileReference->getProperty('extension'), ]; + if ($fileReference->hasProperty('width') && $fileReference->hasProperty('height')) { + $processedProperties['crop'] = $fileReference->getProperty('crop'); + $processedProperties['dimensions'] = [ + 'width' => $fileReference->getProperty('width'), + 'height' => $fileReference->getProperty('height'), + ]; + $processedProperties['cropDimensions'] = [ + 'width' => $this->getCroppedDimensionalProperty($fileReference, 'width', $cropVariant), + 'height' => $this->getCroppedDimensionalProperty($fileReference, 'height', $cropVariant) + ]; + } + $event = $this->eventDispatcher->dispatch( new EnrichFileDataEvent( $originalFileReference,