ContentTools
ContentTools copied to clipboard
Manage images
Add the possibility to use images that is already in the system unstead upload a new image every time.
The image source is an array of strings with the src To set the images is just put this array in IMAGE_UPLOADER dialog new function "addImages"
@Luc-cpl can you provide an example in JS how to add the images? I can then confirm I implemented it correctly and check if it works as expected.
Following the "Handling image uploads" tutorial.
function imageUploader(dialog) {
var image, xhr, xhrComplete, xhrProgress;
var myImages = [ '/image1.jpg', '/image2.jpg', '/image3;jpg', '/image4.jpg' ]; //or use any function that return an array with the urls
dialog.addImages(myImages);
// Set up the event handlers
... event handlers go here ...
}
ContentTools.IMAGE_UPLOADER = imageUploader;
Add one if statement in save event:
dialog.addEventListener('imageuploader.save', function () {
if (!image){
dialog.save();
return;
}
// Rest of code ....
}