From 2bf54a62e2a8b2060b4bc77d397a5297ccb2f83b Mon Sep 17 00:00:00 2001 From: David Toews Date: Fri, 16 Jun 2023 14:02:01 -0600 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=20(sampling=20logic)=20fixes=20?= =?UTF-8?q?conditionals=20and=20removes=20buggy=20resample=20call?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/LazyFocusFitImageExtension.php | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/LazyFocusFitImageExtension.php b/src/LazyFocusFitImageExtension.php index 9f12b50..115087b 100644 --- a/src/LazyFocusFitImageExtension.php +++ b/src/LazyFocusFitImageExtension.php @@ -179,22 +179,21 @@ private function croppedImage($size) if ($this->owner->AspectRatio) { if ($this->owner->AspectRatio > $originalRatio) { $scaledImage = $this->owner - ->Resampled() ->FocusCropHeight(round($this->owner->Width / $this->owner->AspectRatio)) ->ScaleMaxWidth($size); + } else { + $scaledImage = $this->owner + ->FocusCropWidth(round($this->owner->Height * $this->owner->AspectRatio)) + ->ScaleMaxWidth($size); } - $scaledImage = $this->owner - ->Resampled() - ->FocusCropWidth(round($this->owner->Height * $this->owner->AspectRatio)) - ->ScaleMaxWidth($size); + } else { + $scaledImage = $this->owner->ScaleMaxWidth($size); } - } - $scaledImage = $this->owner->Resampled()->ScaleMaxWidth($size); - - return ($this->owner->config()->get('default_webp') || $this->owner->serveWebP) - ? $scaledImage->Webp() - : $scaledImage; + return ($this->owner->config()->get('default_webp') || $this->owner->serveWebP) + ? $scaledImage->Webp() + : $scaledImage; + } } public function AutoSizes()