From acb0e363a14e413e6bf32c34233fef8c2e9a1e89 Mon Sep 17 00:00:00 2001 From: Jake Bentvelzen Date: Tue, 25 Oct 2016 06:22:14 +1100 Subject: [PATCH] FIX CroppedFocusedImage failure case Stop issue where CroppedFocusedImage() doesn't handle the failure case like 'Image::getFormattedImage', as that function implicitly returns null if it cannot find the asset. (#35) --- code/FocusPointImage.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/code/FocusPointImage.php b/code/FocusPointImage.php index 84363ac..0b679da 100755 --- a/code/FocusPointImage.php +++ b/code/FocusPointImage.php @@ -294,6 +294,10 @@ public function CroppedFocusedImage($width, $height, $upscale = true) return $this->owner; } elseif ($cropData = $this->calculateCrop($width, $height)) { $img = $this->owner->getFormattedImage('CroppedFocusedImage', $width, $height, $cropData['CropAxis'], $cropData['CropOffset']); + if (!$img) { + return null; + } + // Update FocusPoint $img->FocusX = $cropData['x']['FocusPoint']; $img->FocusY = $cropData['y']['FocusPoint'];