Media

Manage the media of your online spreadsheets using the following methods.

Documentation

Available methods for worksheet media management.

setMedia

Set the properties of one or more media.

Parameter Description
media[].id Media guid.
media[].src Media src used in floating images.

POST /api/:guid/:worksheetIndex/media

deleteMedia

Remove one or more media.

Parameter Description
ids Media identifiers.

POST /api/:guid/:worksheetIndex/media

Examples

Add media

Add floating image.

const baseUrl = 'http://localhost:8009/api';
const guid = '79b45919-c751-4e2b-a49a-6c1286e2fc03';
const token = 'eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i';
const headers = { 'Authorization': `Bearer ${token}` };

// Add floating image
await fetch(`${baseUrl}/${guid}/0/media`, {
    method: 'POST',
    headers,
    body: new URLSearchParams({
        'media[0][id]': '1e2d0a59-827d-48dc-b86c-cf30bd7c5ea4',
        'media[0][src]': 'https://lemonadejs.com/templates/default/img/components.svg',
        'media[0][left]': '100',
        'media[0][top]': '150',
        'media[0][width]': '200',
        'media[0][height]': '150',
    }),
});

Delete media

const baseUrl = 'http://localhost:8009/api';
const guid = '79b45919-c751-4e2b-a49a-6c1286e2fc03';
const token = 'eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i';
const headers = { 'Authorization': `Bearer ${token}` };

// Remove floating image
await fetch(`${baseUrl}/${guid}/0/media`, {
    method: 'POST',
    headers,
    body: new URLSearchParams({
        'ids[0]': '1e2d0a59-827d-48dc-b86c-cf30bd7c5ea4',
    }),
});