diff --git a/src/FieldType/DBImageResource.php b/src/FieldType/DBImageResource.php index e72e096..e6cfadd 100644 --- a/src/FieldType/DBImageResource.php +++ b/src/FieldType/DBImageResource.php @@ -186,6 +186,10 @@ public function forTemplate() { $asset = $this->asset; + if ($asset == null) { + return ''; + } + $transformations = $asset->getTransformation()->toUrl(); if (!preg_match('~(/|,)f_~', $transformations) && $format = static::config()->get('default_format')) { diff --git a/src/Traits/DPR.php b/src/Traits/DPR.php index 7cadc4a..733b81d 100644 --- a/src/Traits/DPR.php +++ b/src/Traits/DPR.php @@ -14,7 +14,7 @@ public function DPR($dpr) { $clone = $this->clone(); - $clone->asset->delivery(Delivery::dpr($dpr)); + $clone->asset?->delivery(Delivery::dpr($dpr)); return $clone; } diff --git a/src/Traits/Fill.php b/src/Traits/Fill.php index 963d43c..3cf01a0 100644 --- a/src/Traits/Fill.php +++ b/src/Traits/Fill.php @@ -26,7 +26,7 @@ public function Fill($width, $height, $gravity = null) $gravity = $customGravity; } - $clone->asset->resize(Resize::fill($width, $height, $gravity)); + $clone->asset?->resize(Resize::fill($width, $height, $gravity)); return $clone; }