Use Nacl to decode base64 thumbnail data

pull/1/head
ClemDee 5 years ago
parent aae71c43d2
commit 08c006e682

@ -230,20 +230,15 @@ define([
if (!Visible.currently()) { to = window.setTimeout(interval, Thumb.UPDATE_FIRST); }
};
var stringToBlobToUrl = function (b64) {
var byteString = atob(b64.split(',')[1]);
var ab = new ArrayBuffer(byteString.length);
var ia = new Uint8Array(ab);
for (var i = 0; i < byteString.length; i++) {
ia[i] = byteString.charCodeAt(i);
}
var blob = new Blob([ab], {type: "image/png"});
var url = URL.createObjectURL(blob);
return url;
};
var addThumbnail = function (err, thumb, $span, cb) {
var u8 = Nacl.util.decodeBase64(thumb.split(',')[1]);
var blob = new Blob([u8], {
type: 'image/png'
});
var url = URL.createObjectURL(blob);
var img = new Image();
img.src = stringToBlobToUrl(thumb);
img.src = url;
$span.find('.cp-icon').hide();
$span.prepend(img);
cb($(img));

Loading…
Cancel
Save