Skip to content

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

fixing issue with locally linked images

uggrock0e37cf08897c
diff --git a/data/ext/viewerMD/main.js b/data/ext/viewerMD/main.js
index 41f59ed6e..ecf263737 100644
--- a/data/ext/viewerMD/main.js
+++ b/data/ext/viewerMD/main.js
@@ -122,10 +122,14 @@ function setContent(content, fileDirectory) {
// fixing embedding of local images
$htmlContent.find("img[src]").each(function() {
var currentSrc = $(this).attr("src");
- if (currentSrc.indexOf("http://") === 0 || currentSrc.indexOf("https://") === 0 || currentSrc.indexOf("data:") === 0) {
+ if (currentSrc.indexOf("http://") === 0 ||
+ currentSrc.indexOf("https://") === 0 ||
+ currentSrc.indexOf("file://") === 0 ||
+ currentSrc.indexOf("data:") === 0) {
// do nothing if src begins with http(s):// or data:
} else {
- $(this).attr("src", "file://" + fileDirectory + isWin ? "\\" : "/" + currentSrc);
+ var path = "file://" + fileDirectory + (isWin ? "\\" : "/") + currentSrc;
+ $(this).attr("src", path);
}
});
}