How do I preload images into dropzone.js

后端 未结 3 1972
野的像风
野的像风 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:22

    I trying this code and it's working for me :

    Dropzone.options.myDropzone = {
      init: function() {
        let myDropzone = this;
    
        // If you only have access to the original image sizes on your server,
        // and want to resize them in the browser:
        let mockFile = { name: "Filename 2", size: 12345 };
        myDropzone.displayExistingFile(mockFile, "https://i.picsum.photos/id/959/600/600.jpg");
    
        // If the thumbnail is already in the right size on your server:
        let mockFile = { name: "Filename", size: 12345 };
        let callback = null; // Optional callback when it's done
        let crossOrigin = null; // Added to the `img` tag for crossOrigin handling
        let resizeThumbnail = false; // Tells Dropzone whether it should resize the image first
        myDropzone.displayExistingFile(mockFile, "https://i.picsum.photos/id/959/120/120.jpg", callback, crossOrigin, resizeThumbnail);
    
        // If you use the maxFiles option, make sure you adjust it to the
        // correct amount:
        let fileCountOnServer = 2; // The number of files already uploaded
        myDropzone.options.maxFiles = myDropzone.options.maxFiles - fileCountOnServer;
      }
    };
    

提交回复
热议问题