Skip to content

Conversation

@Luc-cpl
Copy link

@Luc-cpl Luc-cpl commented Apr 7, 2018

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 added 2 commits April 7, 2018 13:56
add functions to let the user pass images already in the file system through an array that contains URLs to that images (dialog.addImages( [ "url1", "url2" ] ) )
Add css for images dialog
@PawelGlow
Copy link

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

@Luc-cpl
Copy link
Author

Luc-cpl commented Apr 20, 2018

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

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants