最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to create thumbnail for uploaded images on DropZone.js? - Stack Overflow

programmeradmin3浏览0评论

With below code i got all uploaded images with DropZone,but i now i have a simple problem, it already showing Original images as thumbnail but i need to show thumbnail with base64 same as dropzone made when want to upload new image.

dropzone.js

 init: function() {
         var thisDropzone = this;
        var pageid = $("#pageid").val();
        $.getJSON('plugin/dropzone/get_item_images.php?id='+pageid, function(data) { 

            $.each(data, function(key,value){ 

                var mockFile = { name: value.name, size: value.size }; 

                thisDropzone.options.addedfile.call(thisDropzone, mockFile);
                thisDropzone.options.thumbnail.call(thisDropzone, mockFile, "/admin/uploads/"+value.name);
                thisDropzone.emit("complete", mockFile);

            });
        });

      },

So the problem is with this code i able to show uploaded images with dropzone but it show thumbnail with original images not real thumbnail that created with base64. dropzone made thumbnail with base64 when you want to upload new image, i want to show thumbnail like this.

With below code i got all uploaded images with DropZone,but i now i have a simple problem, it already showing Original images as thumbnail but i need to show thumbnail with base64 same as dropzone made when want to upload new image.

dropzone.js

 init: function() {
         var thisDropzone = this;
        var pageid = $("#pageid").val();
        $.getJSON('plugin/dropzone/get_item_images.php?id='+pageid, function(data) { 

            $.each(data, function(key,value){ 

                var mockFile = { name: value.name, size: value.size }; 

                thisDropzone.options.addedfile.call(thisDropzone, mockFile);
                thisDropzone.options.thumbnail.call(thisDropzone, mockFile, "/admin/uploads/"+value.name);
                thisDropzone.emit("complete", mockFile);

            });
        });

      },

So the problem is with this code i able to show uploaded images with dropzone but it show thumbnail with original images not real thumbnail that created with base64. dropzone made thumbnail with base64 when you want to upload new image, i want to show thumbnail like this.

Share Improve this question edited Dec 9, 2017 at 10:27 Pedram asked Apr 20, 2015 at 5:47 PedramPedram 16.6k10 gold badges47 silver badges73 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 18

You should use createThumbnailFromUrl , orginally posted here

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

评论列表(0)

  1. 暂无评论