diff --git a/src/Module/Photo.php b/src/Module/Photo.php index ddd7b1994d..8bbe391816 100644 --- a/src/Module/Photo.php +++ b/src/Module/Photo.php @@ -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; } diff --git a/src/Protocol/ActivityPub/Processor.php b/src/Protocol/ActivityPub/Processor.php index f21ca48d1a..e714a1d9c1 100644 --- a/src/Protocol/ActivityPub/Processor.php +++ b/src/Protocol/ActivityPub/Processor.php @@ -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; diff --git a/src/Protocol/ActivityPub/Receiver.php b/src/Protocol/ActivityPub/Receiver.php index 1392ec7869..3e8f965e82 100644 --- a/src/Protocol/ActivityPub/Receiver.php +++ b/src/Protocol/ActivityPub/Receiver.php @@ -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'), ]; } }