ContentTools icon indicating copy to clipboard operation
ContentTools copied to clipboard

Manage images

Open Luc-cpl opened this issue 6 years ago • 2 comments

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 avatar Apr 07 '18 19:04 Luc-cpl

@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.

PawelGlow avatar Apr 20 '18 12:04 PawelGlow

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 ....

}

Luc-cpl avatar Apr 20 '18 13:04 Luc-cpl