X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModel%2FPhoto.php;h=82b8bd9dda3867615d146b5701de32df20b1736b;hb=6e31b8d6a54dca2f345aef961539ddae904c0395;hp=16acab69aacd627c2fd721f173e853ac0d8e9785;hpb=7833da5196faf901f52b7f7ad7aa264ceab77592;p=friendica.git diff --git a/src/Model/Photo.php b/src/Model/Photo.php index 16acab69aa..82b8bd9dda 100644 --- a/src/Model/Photo.php +++ b/src/Model/Photo.php @@ -313,6 +313,28 @@ class Photo return $fields; } + /** + * Construct a photo array for a given image data string + * + * @param string $image_data Image data + * @param string $mimetype Image mime type. Is guessed by file name when empty. + * + * @return array + * @throws \Exception + */ + public static function createPhotoForImageData(string $image_data, string $mimetype = ''): array + { + $fields = self::getFields(); + $values = array_fill(0, count($fields), ''); + + $photo = array_combine($fields, $values); + $photo['data'] = $image_data; + $photo['type'] = $mimetype ?: Images::getMimeTypeByData($image_data); + $photo['cacheable'] = false; + + return $photo; + } + /** * Construct a photo array for a system resource image * @@ -647,7 +669,11 @@ class Photo $micro = Contact::getDefaultAvatar($contact, Proxy::SIZE_MICRO); } - return [$image_url, $thumb, $micro]; + $photo = DBA::selectFirst( + 'photo', ['blurhash'], ['uid' => $uid, 'contact-id' => $cid, 'scale' => 4, 'photo-type' => self::CONTACT_AVATAR] + ); + + return [$image_url, $thumb, $micro, $photo['blurhash']]; } /**