From: Vincent Vanwaelscappel Date: Wed, 10 Jul 2019 12:34:42 +0000 (+0200) Subject: #2878 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=28384998402b6cfcf43cde4afa01f54fff703422;p=cubist_cms-back.git #2878 --- 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; + } }