Skip to content
Snippets Groups Projects
Commit 19ff2d0f authored by Frans Saris's avatar Frans Saris Committed by Georg Ringer
Browse files

[BUGFIX] Only apply image cropping when cropping is set

Resolves: #79836
Releases: master
Change-Id: I29fb6f0f31a54b6f20c937881a8b523b844dde69
Reviewed-on: https://review.typo3.org/51749


Tested-by: default avatarTYPO3com <no-reply@typo3.com>
Reviewed-by: default avatarWouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: default avatarAndreas Fernandez <typo3@scripting-base.de>
Reviewed-by: default avatarMarkus Klein <markus.klein@typo3.org>
Tested-by: default avatarMarkus Klein <markus.klein@typo3.org>
Reviewed-by: default avatarGeorg Ringer <georg.ringer@gmail.com>
Tested-by: default avatarGeorg Ringer <georg.ringer@gmail.com>
parent af76b79e
Branches
Tags
No related merge requests found
......@@ -16,7 +16,6 @@ namespace TYPO3\CMS\Fluid\ViewHelpers;
use TYPO3\CMS\Core\Imaging\ImageManipulation\CropVariantCollection;
use TYPO3\CMS\Core\Resource\Exception\ResourceDoesNotExistException;
use TYPO3\CMS\Core\Resource\FileReference;
/**
* Resizes a given image (if required) and renders the respective img tag
......@@ -133,6 +132,7 @@ class ImageViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractTagBasedV
}
$cropVariantCollection = CropVariantCollection::create((string)$cropString);
$cropVariant = $this->arguments['cropVariant'] ?: 'default';
$cropArea = $cropVariantCollection->getCropArea($cropVariant);
$processingInstructions = [
'width' => $this->arguments['width'],
'height' => $this->arguments['height'],
......@@ -140,7 +140,7 @@ class ImageViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractTagBasedV
'minHeight' => $this->arguments['minHeight'],
'maxWidth' => $this->arguments['maxWidth'],
'maxHeight' => $this->arguments['maxHeight'],
'crop' => $cropVariantCollection->getCropArea($cropVariant)->makeAbsoluteBasedOnFile($image),
'crop' => $cropArea->isEmpty() ? null : $cropArea->makeAbsoluteBasedOnFile($image),
];
$processedImage = $this->imageService->applyProcessingInstructions($image, $processingInstructions);
$imageUri = $this->imageService->getImageUri($processedImage, $this->arguments['absolute']);
......
......@@ -122,10 +122,11 @@ class MediaViewHelper extends AbstractTagBasedViewHelper
$cropVariant = $this->arguments['cropVariant'] ?: 'default';
$cropString = $image instanceof FileReference ? $image->getProperty('crop') : '';
$cropVariantCollection = CropVariantCollection::create((string)$cropString);
$cropArea = $cropVariantCollection->getCropArea($cropVariant);
$processingInstructions = [
'width' => $width,
'height' => $height,
'crop' => $cropVariantCollection->getCropArea($cropVariant)->makeAbsoluteBasedOnFile($image),
'crop' => $cropArea->isEmpty() ? null : $cropArea->makeAbsoluteBasedOnFile($image),
];
$imageService = $this->getImageService();
$processedImage = $imageService->applyProcessingInstructions($image, $processingInstructions);
......
......@@ -16,7 +16,6 @@ namespace TYPO3\CMS\Fluid\ViewHelpers\Uri;
use TYPO3\CMS\Core\Imaging\ImageManipulation\CropVariantCollection;
use TYPO3\CMS\Core\Resource\Exception\ResourceDoesNotExistException;
use TYPO3\CMS\Core\Resource\FileReference;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Object\ObjectManager;
use TYPO3\CMS\Extbase\Service\ImageService;
......@@ -119,6 +118,7 @@ class ImageViewHelper extends AbstractViewHelper
$cropVariantCollection = CropVariantCollection::create((string)$cropString);
$cropVariant = $arguments['cropVariant'] ?: 'default';
$cropArea = $cropVariantCollection->getCropArea($cropVariant);
$processingInstructions = [
'width' => $arguments['width'],
'height' => $arguments['height'],
......@@ -126,7 +126,7 @@ class ImageViewHelper extends AbstractViewHelper
'minHeight' => $arguments['minHeight'],
'maxWidth' => $arguments['maxWidth'],
'maxHeight' => $arguments['maxHeight'],
'crop' => $cropVariantCollection->getCropArea($cropVariant)->makeAbsoluteBasedOnFile($image),
'crop' => $cropArea->isEmpty() ? null : $cropArea->makeAbsoluteBasedOnFile($image),
];
$processedImage = $imageService->applyProcessingInstructions($image, $processingInstructions);
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment