kopia lustrzana https://github.com/friendica/friendica
Store incoming blurhash values / display blurhash as preview
rodzic
8d98bca7c2
commit
b79be25aa6
|
@ -272,6 +272,12 @@ class Photo extends BaseApi
|
|||
$height = $media['height'];
|
||||
}
|
||||
|
||||
if (empty($url) && isset($media['blurhash']) && isset($media['width']) && isset($media['height'])) {
|
||||
$image = new Image('', image_type_to_mime_type(IMAGETYPE_WEBP));
|
||||
$image->getFromBlurHash($media['blurhash'], $media['width'], $media['height']);
|
||||
return MPhoto::createPhotoForImageData($image->asString());
|
||||
}
|
||||
|
||||
if (empty($url)) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -152,6 +152,7 @@ class Processor
|
|||
$data['height'] = $attachment['height'] ?? null;
|
||||
$data['width'] = $attachment['width'] ?? null;
|
||||
$data['size'] = $attachment['size'] ?? null;
|
||||
$data['blurhash'] = $attachment['blurhash'] ?? null;
|
||||
$data['preview'] = $attachment['image'] ?? null;
|
||||
$data['description'] = $attachment['name'] ?? null;
|
||||
$data['player-url'] = $attachment['player-url'] ?? null;
|
||||
|
|
|
@ -1677,6 +1677,7 @@ class Receiver
|
|||
'name' => JsonLD::fetchElement($attachment, 'as:name', '@value'),
|
||||
'url' => $imageFullUrl,
|
||||
'image' => $imagePreviewUrl !== $imageFullUrl ? $imagePreviewUrl : null,
|
||||
'blurhash' => JsonLD::fetchElement($attachment, 'toot:blurhash', '@value'),
|
||||
];
|
||||
break;
|
||||
default:
|
||||
|
@ -1693,6 +1694,7 @@ class Receiver
|
|||
'height' => JsonLD::fetchElement($attachment, 'as:height', '@value'),
|
||||
'width' => JsonLD::fetchElement($attachment, 'as:width', '@value'),
|
||||
'image' => JsonLD::fetchElement($attachment, 'as:image', '@id') ?? $icon,
|
||||
'blurhash' => JsonLD::fetchElement($attachment, 'toot:blurhash', '@value'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue