Use the blurhash when the remote picture doesn't load

This commit is contained in:
Michael 2022-12-04 14:58:53 +00:00
parent a5be5b27e3
commit cfe5101b9b
3 changed files with 34 additions and 12 deletions

View file

@ -346,11 +346,14 @@ class Photo
* @param string $url Image URL
* @param int $uid User ID of the requesting person
* @param string $mimetype Image mime type. Is guessed by file name when empty.
* @param string $blurhash The blurhash that will be used to generate a picture when the original picture can't be fetched
* @param int $width Image width
* @param int $height Image height
*
* @return array
* @throws \Exception
*/
public static function createPhotoForExternalResource(string $url, int $uid = 0, string $mimetype = ''): array
public static function createPhotoForExternalResource(string $url, int $uid = 0, string $mimetype = '', string $blurhash = '', int $width = 0, int $height = 0): array
{
if (empty($mimetype)) {
$mimetype = Images::guessTypeByExtension($url);
@ -364,6 +367,9 @@ class Photo
$photo['backend-ref'] = json_encode(['url' => $url, 'uid' => $uid]);
$photo['type'] = $mimetype;
$photo['cacheable'] = true;
$photo['blurhash'] = $blurhash;
$photo['width'] = $width;
$photo['height'] = $height;
return $photo;
}