How to generate thumbnails for images stored on the server using dropzone?

前端 未结 1 529
轮回少年
轮回少年 2021-01-12 21:53

I\'m trying to display images already stored on the server. I display in dropzone, using the following code:

myDropzone.emit(\"addedfile\", mockFile);
myDrop         


        
1条回答
  •  生来不讨喜
    2021-01-12 22:42

    I am recommending you create thumbnails on the server, because otherwise your users need to download all images in their original size, just to view small thumbnails.

    That being said, if you still want to go ahead, and download the originals and resize in the browser, I just released Dropzone v4.0.1 to include the function createThumbnailFromUrl().

    Use it like this:

    myDropzone.emit("addedfile", mockFile);
    myDropzone.createThumbnailFromUrl(mockFile, '/your-image.jpg');
    

    (Side note: the image needs to be hosted on the same server, otherwise you'll get a Cross-Origin error)

    0 讨论(0)
提交回复
热议问题