Skip to content

Commit 59a66e5

Browse files
committed
Update image path handling and bump version to 0.9.0
1 parent 18d9852 commit 59a66e5

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
"authorUrl": "https://atbug.com",
77
"isDesktopOnly": true,
88
"minAppVersion": "0.11.0",
9-
"version": "0.8.2"
9+
"version": "0.9.0"
1010
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "obsidian-image-upload-toolkit",
3-
"version": "0.8.2",
3+
"version": "0.9.0",
44
"description": "",
55
"author": "addozhang",
66
"main": "main.js",

src/uploader/imageTagProcessor.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export default class ImageTagProcessor {
3636
const images = this.getImageLists(value);
3737
const uploader = this.imageUploader;
3838
for (const image of images) {
39-
if ((await this.app.vault.getAbstractFileByPath(normalizePath(image.path))) == null) {
39+
if (this.app.vault.getAbstractFileByPath(normalizePath(image.path)) == null) {
4040
new Notice(`Can NOT locate ${image.name} with ${image.path}, please check image path or attachment option in plugin setting!`, 10000);
4141
console.log(`${normalizePath(image.path)} not exist`);
4242
break;
@@ -82,13 +82,13 @@ export default class ImageTagProcessor {
8282
const mdMatches = value.matchAll(MD_REGEX);
8383
for (const match of wikiMatches) {
8484
const name = match[1]
85-
var path_name = name
85+
let path_name = name
8686
if (name.endsWith('.excalidraw')) {
8787
path_name = name + '.png'
8888
}
8989
images.push({
9090
name: name,
91-
path: this.settings.attachmentLocation + '/' + path_name,
91+
path: path.join(this.settings.attachmentLocation, path_name),
9292
source: match[0],
9393
url: '',
9494
})
@@ -97,10 +97,14 @@ export default class ImageTagProcessor {
9797
if (match[2].startsWith('http://') || match[2].startsWith('https://')) {
9898
continue
9999
}
100-
const decodedPath = decodeURI(match[2]);
100+
let decodedPath = decodeURI(match[2]);
101+
const parentPath = this.app.workspace.getActiveFile().parent.path;
102+
if (decodedPath.startsWith('./')) {
103+
decodedPath = decodedPath.substring(2);
104+
}
101105
images.push({
102106
name: decodedPath,
103-
path: decodedPath,
107+
path: path.join(parentPath, decodedPath),
104108
source: match[0],
105109
url: '',
106110
})

0 commit comments

Comments
 (0)