Skip to content

ImageBlock

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

Image content block.

new ImageBlock(data): ImageBlock;

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

ParameterType
dataImageBlockData

ImageBlock

readonly type: "imageBlock";

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

Discriminator for image content.


readonly format: ImageFormat;

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

Image format.

ImageBlockData.format


readonly source: ImageSource;

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

Image source.

ImageBlockData.source

toJSON(): {
image: {
format: ImageFormat;
source: | {
bytes: string;
}
| {
s3Location: {
uri: string;
bucketOwner?: string;
};
}
| {
url: string;
};
};
};

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

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:204
image.formatImageFormatImage format.src/types/media.ts:145
image.source| { bytes: string; } | { s3Location: { uri: string; bucketOwner?: string; }; } | { url: string; }Image source.src/types/media.ts:150
JSONSerializable.toJSON

static fromJSON(data): ImageBlock;

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

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