From 28384998402b6cfcf43cde4afa01f54fff703422 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Wed, 10 Jul 2019 14:34:42 +0200 Subject: [PATCH] #2878 --- src/app/Magic/PageData.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/app/Magic/PageData.php b/src/app/Magic/PageData.php index ecf0184..f3ac10f 100644 --- a/src/app/Magic/PageData.php +++ b/src/app/Magic/PageData.php @@ -93,4 +93,25 @@ class PageData implements \ArrayAccess { $this->unset($name); } + + public function getImageURL($offset, $conversionName = '', $default = null) + { + if (!$this->exists($offset)) { + return $default; + } + if (null === $this->getEntity()) { + return $default; + } + $collection = $this->get($offset); + if (null === $collection || !$collection) { + return $default; + } + + $res = $this->getEntity()->getFirstMediaUrl($collection, $conversionName); + if (!$res) { + return $default; + } + + return $res; + } } -- 2.39.5