0

I'm using dropzone as a library to display uploaded images and upload new ones. Its default behavior is to sort the images from first to last, but I want to sort the images from last to first, I mean reverse the default order. this is my dropzone object:

myDropzone = new Dropzone("div#dropZone", {
        clickable: "#mediaCenterInput",
        paramName: "image",
        dictDefaultMessage: "There is no images yet.",
        url: "/resource",
        maxFilesize: 10,
        maxFiles: 1024,
        parallelUploads: 1,
        acceptedFiles: "image/*",
        previewsContainer: "#dropZone",
        previewTemplate: template,
    });

in the event 'addedfile' i tried to reverse the order of files into 'myDropzone' object like that, but it doesn´t work;

myDropzone.on("addedfile", function (file) {
        // some code ...
        let myArray = myDropzone.files;
        myArray.sort(function(a, b) {
            return b.id - a.id;
        });
        myDropzone.files = myArray;
    });

I've watched some question like:

Is there a way to do drag-and-drop re-ordering of the preview elements in a dropzone.js instance?

Dropzone.js Sortable files from server loaded files

Dropzone images reordering

But they don't work for me. Any idea?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.