]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Photo.php
Merge pull request #10014 from annando/issue-9906-encore
[friendica.git] / src / Model / Photo.php
index 0f03b54b0dbac9677dfaca7ee2cb48a6211f5e76..e5b2ef87b96e3654901cf12c6f2c0b5721a3fd52 100644 (file)
@@ -178,7 +178,7 @@ class Photo
 
 
        /**
-        * Get Image object for given row id. null if row id does not exist
+        * Get Image data for given row id. null if row id does not exist
         *
         * @param array $photo Photo data. Needs at least 'id', 'type', 'backend-class', 'backend-ref'
         *
@@ -186,7 +186,7 @@ class Photo
         * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         * @throws \ImagickException
         */
-       public static function getImageForPhoto(array $photo)
+       public static function getImageDataForPhoto(array $photo)
        {
                $backendClass = DI::storageManager()->getByName($photo['backend-class'] ?? '');
                if ($backendClass === null) {
@@ -200,7 +200,21 @@ class Photo
                        $backendRef = $photo['backend-ref'] ?? '';
                        $data = $backendClass->get($backendRef);
                }
+               return $data;
+       }
 
+       /**
+        * Get Image object for given row id. null if row id does not exist
+        *
+        * @param array $photo Photo data. Needs at least 'id', 'type', 'backend-class', 'backend-ref'
+        *
+        * @return \Friendica\Object\Image
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+        * @throws \ImagickException
+        */
+       public static function getImageForPhoto(array $photo)
+       {
+               $data = self::getImageDataForPhoto($photo);
                if (empty($data)) {
                        return null;
                }
@@ -305,6 +319,7 @@ class Photo
                        "contact-id" => $cid,
                        "guid" => $guid,
                        "resource-id" => $rid,
+                       "hash" => md5($Image->asString()),
                        "created" => $created,
                        "edited" => DateTimeFormat::utcNow(),
                        "filename" => basename($filename),