[BUGFIX] Avoid calculating crop areas, when files have no size 92/52192/2
authorHelmut Hummel <typo3@helhum.io>
Mon, 27 Mar 2017 17:09:29 +0000 (19:09 +0200)
committerWouter Wolters <typo3@wouterwolters.nl>
Tue, 28 Mar 2017 18:40:51 +0000 (20:40 +0200)
When file relations are added, the crop area of these is calculated,
even if they are not images.

We avoid that by only doing this processing, when the file
has a width property.

Resolves: #80071
Releases: master
Change-Id: I42924b271e5a6697d35ffb7d5f322f555139ec57
Reviewed-on: https://review.typo3.org/52192
Reviewed-by: Thomas Hohn <thomas@hohn.dk>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Jigal van Hemert <jigal.van.hemert@typo3.org>
Tested-by: Jigal van Hemert <jigal.van.hemert@typo3.org>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
typo3/sysext/backend/Classes/Form/Element/ImageManipulationElement.php

index b87eb48..85f7677 100644 (file)
@@ -289,11 +289,11 @@ class ImageManipulationElement extends AbstractFormElement
     protected function processConfiguration(array $config, string &$elementValue, File $file)
     {
         $cropVariantCollection = CropVariantCollection::create($elementValue, $config['cropVariants']);
-        if (empty($config['readOnly'])) {
+        if (empty($config['readOnly']) && !empty($file->getProperty('width'))) {
             $cropVariantCollection = $cropVariantCollection->applyRatioRestrictionToSelectedCropArea($file);
+            $elementValue = (string)$cropVariantCollection;
         }
         $config['cropVariants'] = $cropVariantCollection->asArray();
-        $elementValue = (string)$cropVariantCollection;
         $config['allowedExtensions'] = implode(', ', GeneralUtility::trimExplode(',', $config['allowedExtensions'], true));
         return $config;
     }