Skip to content

TagSpaces is an offline, open source, document manager with tagging support

Moved getBase64Image to utils.js Fixed mozilla security exception

Borislav Sapundzhieve9064e753d30
diff --git a/data/ext/editorHTML/extension.js b/data/ext/editorHTML/extension.js
index c1d6a5926..e2f34f3e7 100644
--- a/data/ext/editorHTML/extension.js
+++ b/data/ext/editorHTML/extension.js
@@ -135,7 +135,7 @@ define(function(require, exports, module) {
while (match = rex.exec(cleanedContent)) {
imgUrl = match[1];
console.log("URLs: " + imgUrl);
- urls.push([imgUrl, getBase64Image(imgUrl)]);
+ urls.push([imgUrl, TSCORE.Utils.getBase64Image(imgUrl)]);
}
urls.forEach(function(dataURLObject) {
@@ -154,17 +154,6 @@ define(function(require, exports, module) {
return htmlContent;
};
- function getBase64Image(imgURL) {
- var canvas = document.createElement("canvas");
- var img = new Image();
- img.src = imgURL;
- canvas.width = img.width;
- canvas.height = img.height;
- var ctx = canvas.getContext("2d");
- ctx.drawImage(img, 0, 0);
- return canvas.toDataURL("image/png");
- }
-
// Extension Vars
exports.Title = extensionTitle;
exports.ID = extensionID;
diff --git a/data/js/utils.js b/data/js/utils.js
index 2bde293ce..55f909d80 100644
--- a/data/js/utils.js
+++ b/data/js/utils.js
@@ -28,7 +28,20 @@ define(function(require, exports, module) {
return new window.Blob([arrBuff], {type:mime});
}
+ function getBase64Image(imgURL) {
+ var canvas = document.createElement("canvas");
+ var img = new Image();
+ img.crossOrigin = 'anonymous';
+ img.src = imgURL;
+ canvas.width = img.width;
+ canvas.height = img.height;
+ var ctx = canvas.getContext("2d");
+ ctx.drawImage(img, 0, 0);
+ return canvas.toDataURL("image/png");
+ }
+
exports.arrayBufferToDataURL = arrayBufferToDataURL;
exports.base64ToArrayBuffer = base64ToArrayBuffer;
exports.dataURLtoBlob = dataURLtoBlob;
+ exports.getBase64Image = getBase64Image;
});