getStates#
Checks which images have been removed from the content.
let changes = app.image.getStates();
for (let [key, item] of Object.entries(changes)) {
if (item.status === false) {
// image was deleted
}
else {
// image is still in the content
}
}
insert#
Inserts an image to content.
const data = {
src: 'photo.jpg',
alt: 'My image',
id: 'some-id',
width: '200px',
url: 'https://example.com',
target: '_blank',
caption: 'Caption of the image'
};
const imageInstance = app.image.insert(data);
Inserts multiple images to the content.
const data = [{
src: '/assets/img/photo-1.jpg',
alt: 'My image',
caption: 'Caption of the image 1'
},
{
src: '/assets/img/photo-2.jpg',
alt: 'My image',
caption: 'Caption of the image 2'
}];
const imageInstances = app.image.insert(data);
update#
Updates the properties of the currently selected image.
Update the src of the image
const data = {
src: 'photo2.jpg'
};
const imageInstance = app.image.update(data);
Update the properties of the image
const data =
width: '200px',
url: 'https://example.com',
caption: 'Caption of the image'
};
const imageInstance = app.image.update(data);
get#
Returns the instance of the currently selected image.
const imageInstance = app.image.get();
if (imageInstance) {
imageInstance.getImage().addClass('image-classname');
}
Here is a list of all available image instance methods:
- getAlt
- getId
- getSrc
- getSrcset
- getWidth
- getCaption
- getUrl
- getTarget
- setAlt
- setId
- setSrc
- setSrcset
- setWidth
- setCaption
- setUrl
- setTarget