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

| Parameter | Type | | --------- | -------------------------------------- | | data | ImageBlockData |

ImageBlock

readonly type: "imageBlock";

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

Discriminator for image content.


readonly format: "png" | "jpeg" | "jpg" | "gif" | "webp";

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: "png" | "jpeg" | "jpg" | "gif" | "webp";
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: "png" | "jpeg" | "jpg" | "gif" | "webp";
source: | {
bytes: string;
}
| {
location: {
type: "s3";
uri: string;
bucketOwner?: string;
};
}
| {
url: string;
};
};
}

| Name | Type | Description | Defined in | | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | | image | { format: "png" | "jpeg" | "jpg" | "gif" | "webp"; source: | { bytes: string; } | { location: { type: "s3"; uri: string; bucketOwner?: string; }; } | { url: string; }; } | - | src/types/media.ts:220 | | image.format | "png" | "jpeg" | "jpg" | "gif" | "webp" | Image 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.

| Parameter | Type | Description | | ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ | | data | { image: { format: "png" | "jpeg" | "jpg" | "gif" | "webp"; 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: "png" | "jpeg" | "jpg" | "gif" | "webp"; source: | { bytes: string | Uint8Array<ArrayBufferLike>; } | { location: { type: "s3"; uri: string; bucketOwner?: string; }; } | { url: string; }; } | - | | data.image.format | "png" | "jpeg" | "jpg" | "gif" | "webp" | Image format. | | data.image.source | | { bytes: string | Uint8Array<ArrayBufferLike>; } | { location: { type: "s3"; uri: string; bucketOwner?: string; }; } | { url: string; } | Image source. |

ImageBlock

ImageBlock instance