Add more BlurHash to avoid not being able to display some picture

This commit is contained in:
Michael 2022-12-11 09:56:30 +00:00
parent 183e9dc7b2
commit bf7df13855
9 changed files with 101 additions and 28 deletions

View file

@ -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']];
}
/**