Skip to content

Commit c40b340

Browse files
committed
[BUGFIX] no not try to scale an non-processable image
Like PDF if there is no PDF extension available. solves: #14
1 parent c00c75b commit c40b340

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

Classes/ViewHelpers/Image/Modify/ScaleViewHelper.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
use Sitegeist\MediaComponents\Domain\Model\ImageSource;
77
use SMS\FluidComponents\Interfaces\ImageWithDimensions;
8+
use SMS\FluidComponents\Interfaces\ProcessableImage;
89
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
910

1011
class ScaleViewHelper extends AbstractViewHelper
@@ -20,9 +21,17 @@ public function initializeArguments(): void
2021
public function render(): ImageSource
2122
{
2223
$imageSource = $this->arguments['imageSource'] ?? $this->renderChildren();
23-
if (!($imageSource->getOriginalImage() instanceof ImageWithDimensions)) {
24+
if (
25+
!($imageSource->getOriginalImage() instanceof ImageWithDimensions)
26+
|| !($imageSource->getOriginalImage() instanceof ProcessableImage)
27+
) {
2428
return $imageSource;
2529
}
30+
31+
if (!$imageSource->getCroppedHeight() || !$imageSource->getCroppedWidth()) {
32+
return $imageSource;
33+
}
34+
2635
if ($this->arguments['height'] || $this->arguments['width']) {
2736
$heightFactor = $this->arguments['height'] ? $this->arguments['height'] / $imageSource->getCroppedHeight() : 1;
2837
$widthFactor = $this->arguments['width'] ? $this->arguments['width'] / $imageSource->getCroppedWidth() : 1;

0 commit comments

Comments
 (0)