How do I preload images into dropzone.js

后端 未结 3 1947
野的像风
野的像风 2020-12-23 11:29

I have a dropzone.js instance on a web page with the following options:

autoProcessQueue:false
uploadMultiple:true
parallelUploads:20
maxFiles:20
         


        
3条回答
  •  生来不讨喜
    2020-12-23 12:19

    Proper way to do it is to use .emit method provided by on dropzone js to add a file and thumbnail to preload images from the server. See sample code below. Taken from https://github.com/enyo/dropzone/wiki/FAQ#how-to-show-files-already-stored-on-server

    // Create the mock file:
    var mockFile = { name: "Filename", size: 12345 };
    
    // Call the default addedfile event handler
    myDropzone.emit("addedfile", mockFile);
    
    // And optionally show the thumbnail of the file:
    myDropzone.emit("thumbnail", mockFile, "/image/url");
    

    .emit method from dropzone will trigger init function and if you have any addedfile event callback written for it. e.g. I am using addedfile event add remove button and also attached delete image functionality.

提交回复
热议问题