Store incoming blurhash values / display blurhash as preview

pull/15145/head
Michael 2025-09-08 11:47:01 +00:00
rodzic 8d98bca7c2
commit b79be25aa6
3 zmienionych plików z 9 dodań i 0 usunięć

Wyświetl plik

@ -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;
}

Wyświetl plik

@ -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;

Wyświetl plik

@ -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'),
];
}
}