WebUploader using locally-generated thumbnails

All the people in python Dafa, has not been immune, Flask take a stand, image upload + identification.

Want to see local thumbnails directly from the file path, due to security restrictions chrome, no option but to use FileReader html5, but also need to meet the input tag, however, webuploader There is no input tag ah

Toss for an hour, to no avail, this time had looking through the official API.

It was found that a similar feature in the official demo in, http://fex.baidu.com/webuploader/demo.html

To double source, http://fex.baidu.com/webuploader/js/demo.js  found this function makeThumb

A look at the official API, immediately arrange plainly.

The following code is attached, in

uploader.on('fileQueued', function(file) {}

Plus function in:

var $img = $('<div></div>');
uploader.makeThumb(file, function (error, src) {
if (error) {
return;
}
var img = $('<img src="' + src + '">');
$img.append(img);
}, 100, 100);

Here is a thumbnail size of 100, then $ img element into where you want to go to. For example, I want to insert into

<Td class = "info"> <span> </ span> </ td> td this gone,
$list.find('td.info span').append($img);
 

 

Guess you like

Origin www.cnblogs.com/marszhw/p/12154510.html