ImageBlock
Defined in: src/types/media.ts:205
Image content block.
Implements
Section titled “Implements”ImageBlockDataJSONSerializable<{image:Serialized<ImageBlockData>; }>
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new ImageBlock(data): ImageBlock;Defined in: src/types/media.ts:221
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
data | ImageBlockData |
Returns
Section titled “Returns”ImageBlock
Properties
Section titled “Properties”readonly type: "imageBlock";Defined in: src/types/media.ts:209
Discriminator for image content.
format
Section titled “format”readonly format: ImageFormat;Defined in: src/types/media.ts:214
Image format.
Implementation of
Section titled “Implementation of”source
Section titled “source”readonly source: ImageSource;Defined in: src/types/media.ts:219
Image source.
Implementation of
Section titled “Implementation of”Methods
Section titled “Methods”toJSON()
Section titled “toJSON()”toJSON(): { image: { format: ImageFormat; source: | { bytes: string; } | { s3Location: { uri: string; bucketOwner?: string; }; } | { url: string; }; };};Defined in: src/types/media.ts:253
Serializes the ImageBlock to a JSON-compatible ContentBlockData object. Called automatically by JSON.stringify(). Uint8Array bytes are encoded as base64 string.
Returns
Section titled “Returns”{ image: { format: ImageFormat; source: | { bytes: string; } | { s3Location: { uri: string; bucketOwner?: string; }; } | { url: string; }; };}| Name | Type | Description | Defined in |
|---|---|---|---|
image | { format: ImageFormat; source: | { bytes: string; } | { s3Location: { uri: string; bucketOwner?: string; }; } | { url: string; }; } | - | src/types/media.ts:253 |
image.format | ImageFormat | Image format. | src/types/media.ts:194 |
image.source | | { bytes: string; } | { s3Location: { uri: string; bucketOwner?: string; }; } | { url: string; } | Image source. | src/types/media.ts:199 |
Implementation of
Section titled “Implementation of”JSONSerializable.toJSONfromJSON()
Section titled “fromJSON()”static fromJSON(data): ImageBlock;Defined in: src/types/media.ts:277
Creates an ImageBlock instance from its wrapped data format. Base64-encoded bytes are decoded back to Uint8Array.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
data | { image: { format: ImageFormat; source: | { bytes: string | Uint8Array<ArrayBufferLike>; } | { s3Location: { uri: string; bucketOwner?: string; }; } | { url: string; }; }; } | Wrapped ImageBlockData to deserialize (accepts both string and Uint8Array for bytes) |
data.image | { format: ImageFormat; source: | { bytes: string | Uint8Array<ArrayBufferLike>; } | { s3Location: { uri: string; bucketOwner?: string; }; } | { url: string; }; } | - |
data.image.format | ImageFormat | Image format. |
data.image.source | | { bytes: string | Uint8Array<ArrayBufferLike>; } | { s3Location: { uri: string; bucketOwner?: string; }; } | { url: string; } | Image source. |
Returns
Section titled “Returns”ImageBlock
ImageBlock instance