[BUGFIX] Check if fileObject width is greater than 0, if not use maxWidth 57/60357/2
authorRiny van Tiggelen <info@online-gamer.nl>
Mon, 1 Apr 2019 16:00:50 +0000 (18:00 +0200)
committerRichard Haeser <richard@maxserv.com>
Tue, 2 Apr 2019 09:22:45 +0000 (11:22 +0200)
If you want to use a PDF inside the GalleryProcessor, the mediaWidth is
always 0, because there are no dimensions in the metadata. This fix
will use the maxMediaWidth if the dimension is not greater than 0.

Resolves: #88047
Releases: master, 9.5
Change-Id: I56a2dc2a946385931172c86e54711ba8aa3f6637
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/60357
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Koen Wouters <koen.wouters@maxserv.com>
Tested-by: Richard Haeser <richard@maxserv.com>
Reviewed-by: Frans Saris <franssaris@gmail.com>
Reviewed-by: Koen Wouters <koen.wouters@maxserv.com>
Reviewed-by: Richard Haeser <richard@maxserv.com>
typo3/sysext/frontend/Classes/DataProcessing/GalleryProcessor.php

index 0b54e0c..e3bbcb8 100644 (file)
@@ -450,7 +450,8 @@ class GalleryProcessor implements DataProcessorInterface
         } else {
             $maxMediaWidth = (int)($galleryWidthMinusBorderAndSpacing / $this->galleryData['count']['columns']);
             foreach ($this->fileObjects as $key => $fileObject) {
-                $mediaWidth = min($maxMediaWidth, $this->getCroppedDimensionalProperty($fileObject, 'width'));
+                $croppedWidth = $this->getCroppedDimensionalProperty($fileObject, 'width');
+                $mediaWidth = $croppedWidth > 0 ? min($maxMediaWidth, $croppedWidth) : $maxMediaWidth;
                 $mediaHeight = floor(
                     $this->getCroppedDimensionalProperty($fileObject, 'height') * ($mediaWidth / max($this->getCroppedDimensionalProperty($fileObject, 'width'), 1))
                 );