]> _ Git - cubist_cms-back.git/commitdiff
#2878
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 10 Jul 2019 12:34:42 +0000 (14:34 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 10 Jul 2019 12:34:42 +0000 (14:34 +0200)
src/app/Magic/PageData.php

index ecf01842930dfb0382859d4c904b5eb32b598080..f3ac10fb0e3509a6664f9cea7cfd203feecb68bb 100644 (file)
@@ -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;
+    }
 }