From 49e1fc1066594fefa1735c01d862cc6db77411ab Mon Sep 17 00:00:00 2001 From: Martin Ficzel Date: Thu, 6 Sep 2018 16:12:49 +0200 Subject: [PATCH] BUGFIX: Handle altered handling of setWidth and setHeight during scaling properly --- Classes/EelHelpers/AbstractImageSourceHelper.php | 1 + Classes/EelHelpers/AssetImageSourceHelper.php | 8 ++++---- Classes/EelHelpers/DummyImageSourceHelper.php | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Classes/EelHelpers/AbstractImageSourceHelper.php b/Classes/EelHelpers/AbstractImageSourceHelper.php index 1c90d92..4848efc 100644 --- a/Classes/EelHelpers/AbstractImageSourceHelper.php +++ b/Classes/EelHelpers/AbstractImageSourceHelper.php @@ -97,6 +97,7 @@ public function srcset($mediaDescriptors): string $srcsetArray[] = $scaled->src() . ' ' . $factor . 'x'; } } + \Neos\Flow\var_dump([$descriptors,$srcsetArray]); return implode(', ', $srcsetArray); } else { return $this->src(); diff --git a/Classes/EelHelpers/AssetImageSourceHelper.php b/Classes/EelHelpers/AssetImageSourceHelper.php index 68b336e..283f8a7 100644 --- a/Classes/EelHelpers/AssetImageSourceHelper.php +++ b/Classes/EelHelpers/AssetImageSourceHelper.php @@ -69,15 +69,15 @@ public function scale(float $factor): ImageSourceHelperInterface $scaledHelper = clone($this); if ($this->targetWidth) { - $scaledHelper->setWidth(round($factor * $this->targetWidth)); + $scaledHelper = $scaledHelper->setWidth(round($factor * $this->targetWidth)); } else { - $scaledHelper->setWidth(round($factor * $this->asset->getWidth())); + $scaledHelper = $scaledHelper->setWidth(round($factor * $this->asset->getWidth())); } if ($this->targetHeight) { - $scaledHelper->setHeight(round($factor * $this->targetHeight)); + $scaledHelper = $scaledHelper->setHeight(round($factor * $this->targetHeight)); } else if (!$this->targetWidth) { - $scaledHelper->setHeight(round($factor * $this->asset->getHeight())); + $scaledHelper = $scaledHelper->setHeight(round($factor * $this->asset->getHeight())); } return $scaledHelper; diff --git a/Classes/EelHelpers/DummyImageSourceHelper.php b/Classes/EelHelpers/DummyImageSourceHelper.php index ca28a37..34921ae 100644 --- a/Classes/EelHelpers/DummyImageSourceHelper.php +++ b/Classes/EelHelpers/DummyImageSourceHelper.php @@ -72,10 +72,10 @@ public function scale(float $factor): ImageSourceHelperInterface $scaledHelper->setBaseHeight(round($factor * $this->baseHeight)); if ($this->targetWidth) { - $scaledHelper->setWidth(round($factor * $this->targetWidth)); + $scaledHelper = $scaledHelper->setWidth(round($factor * $this->targetWidth)); } if ($this->targetHeight) { - $scaledHelper->setHeight(round($factor * $this->targetHeight)); + $scaledHelper = $scaledHelper->setHeight(round($factor * $this->targetHeight)); } return $scaledHelper;