Skip to content

ImageBlock

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

Image content block.

new ImageBlock(data): ImageBlock;

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

ParameterType
dataImageBlockData

ImageBlock

readonly type: "imageBlock";

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

Discriminator for image content.


readonly format: ImageFormat;

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

Image format.

ImageBlockData.format


readonly source: ImageSource;

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

Image source.

ImageBlockData.source

toJSON(): {
image: {
format: ImageFormat;
source: | {
bytes: string;
}
| {
location: {
type: "s3";
uri: string;
bucketOwner?: string;
};
}
| {
url: string;
};
};
};

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

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;
}
| {
location: {
type: "s3";
uri: string;
bucketOwner?: string;
};
}
| {
url: string;
};
};
}
NameTypeDescriptionDefined in
image{ format: ImageFormat; source: | { bytes: string; } | { location: { type: "s3"; uri: string; bucketOwner?: string; }; } | { url: string; }; }-src/types/media.ts:220
image.formatImageFormatImage format.src/types/media.ts:161
image.source| { bytes: string; } | { location: { type: "s3"; uri: string; bucketOwner?: string; }; } | { url: string; }Image source.src/types/media.ts:166
JSONSerializable.toJSON

static fromJSON(data): ImageBlock;

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

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

ImageBlock

ImageBlock instance