Skip to content

ImageBlock

Defined in: src/types/media.ts:205

Image content block.

new ImageBlock(data): ImageBlock;

Defined in: src/types/media.ts:221

ParameterType
dataImageBlockData

ImageBlock

readonly type: "imageBlock";

Defined in: src/types/media.ts:209

Discriminator for image content.


readonly format: ImageFormat;

Defined in: src/types/media.ts:214

Image format.

ImageBlockData.format


readonly source: ImageSource;

Defined in: src/types/media.ts:219

Image source.

ImageBlockData.source

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.

{
image: {
format: ImageFormat;
source: | {
bytes: string;
}
| {
s3Location: {
uri: string;
bucketOwner?: string;
};
}
| {
url: string;
};
};
}
NameTypeDescriptionDefined in
image{ format: ImageFormat; source: | { bytes: string; } | { s3Location: { uri: string; bucketOwner?: string; }; } | { url: string; }; }-src/types/media.ts:253
image.formatImageFormatImage format.src/types/media.ts:194
image.source| { bytes: string; } | { s3Location: { uri: string; bucketOwner?: string; }; } | { url: string; }Image source.src/types/media.ts:199
JSONSerializable.toJSON

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.

ParameterTypeDescription
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.formatImageFormatImage format.
data.image.source| { bytes: string | Uint8Array<ArrayBufferLike>; } | { s3Location: { uri: string; bucketOwner?: string; }; } | { url: string; }Image source.

ImageBlock

ImageBlock instance