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
}
}
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);
Updates the properties of the currently selected image.
const data = {
src: 'photo2.jpg'
};
const imageInstance = app.image.update(data);
const data =
width: '200px',
url: 'https://example.com',
caption: 'Caption of the image'
};
const imageInstance = app.image.update(data);
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: