2.9 KiB
NIP-92
Media Attachments Metadata (imeta)
Media attachments (images, videos, and other files) may be added to events by including a URL in the event content, along with a matching imeta tag.
imeta ("inline metadata") tags MAY add information about media URLs in the event's content. Each imeta tag SHOULD match a URL in the event content. Clients MAY replace imeta URLs with rich previews.
The imeta tag is variadic, and each entry is a space-delimited key/value pair.
Each imeta tag MUST have a url, and at least one other field. imeta MAY include
any field specified by NIP 94. There SHOULD be only one imeta tag per URL.
Example
{
"content": "More image metadata tests don’t mind me https://nostr.build/i/my-image.jpg",
"kind": 1,
"tags": [
[
"imeta",
"url https://nostr.build/i/my-image.jpg",
"m image/jpeg",
"blurhash eVF$^OI:${M{o#*0-nNFxakD-?xVM}WEWB%iNKxvR-oetmo#R-aen$",
"dim 3024x4032",
"alt A scenic photo overlooking the coast of Costa Rica",
"x <sha256 hash as specified in NIP 94>",
"fallback https://nostrcheck.me/alt1.jpg",
"fallback https://void.cat/alt1.jpg"
]
]
}
Recommended client behavior
When uploading files during a new post, clients MAY include this metadata after the file is uploaded and included in the post.
When pasting URLs during post composition, the client MAY download the file and add this metadata before the post is sent.
The client MAY ignore imeta tags that do not match the URL in the event content.
Profile metadata
A kind 0 event MAY carry imeta tags describing the images named by the picture and banner fields of its stringified JSON content (NIP-01, NIP-24). This gives profile images the same fallback, blurhash, dim, alt, and other NIP-94 fields available to any other attachment.
An imeta tag describes a field only when its url is exactly equal to that field's value. Tags whose url matches neither field SHOULD be ignored.
{
"kind": 0,
"content": "{\"name\":\"luna\",\"picture\":\"https://blossom.example/1f2e...a9.jpg\",\"banner\":\"https://blossom.example/7c3d...04.webp\"}",
"tags": [
[
"imeta",
"url https://blossom.example/1f2e...a9.jpg",
"m image/jpeg",
"x 1f2e...a9",
"dim 400x400",
"blurhash LEHV6nWB2yk8pyo0adR*.7kCMdnj",
"fallback https://mirror.example/1f2e...a9.jpg"
],
[
"imeta",
"url https://blossom.example/7c3d...04.webp",
"m image/webp",
"x 7c3d...04",
"dim 1500x500"
]
]
}
Clients SHOULD try the declared fallback URLs when the primary URL fails to load.
Since kind 0 is replaceable, clients publishing a new kind 0 SHOULD carry over the imeta tags for a picture or banner that hasn't changed, and drop the tags for images that are no longer in use.