Skip to content

Commit 0bf58d2

Browse files
committed
Fix image path resolution in imageTagProcessor and bump version to 1.1.0
1 parent a2ac5c6 commit 0bf58d2

File tree

3 files changed

+19
-18
lines changed

3 files changed

+19
-18
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": "1.0.1"
9+
"version": "1.1.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": "1.0.1",
3+
"version": "1.1.0",
44
"description": "",
55
"author": "addozhang",
66
"main": "main.js",

src/uploader/imageTagProcessor.ts

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -181,27 +181,28 @@ export default class ImageTagProcessor {
181181
}
182182

183183
private resolveImagePath(imageName: string): ResolvedImagePath {
184-
const pathName = imageName.endsWith('.excalidraw') ?
184+
let pathName = imageName.endsWith('.excalidraw') ?
185185
imageName + '.png' :
186186
imageName;
187-
188-
const imagePath = path.join(this.settings.attachmentLocation, pathName);
189-
if (this.app.vault.getAbstractFileByPath(normalizePath(imagePath)) != null) {
190-
return {resolvedPath: imagePath, name: pathName};
187+
188+
if(imageName.indexOf('/') < 0) {
189+
pathName = path.join(this.app.vault.config.attachmentFolderPath, pathName);
190+
if (this.app.vault.config.attachmentFolderPath.startsWith('.')) {
191+
pathName = './' + pathName;
192+
}
191193
}
192-
193-
let finalPathName = pathName;
194+
194195
if (pathName.startsWith('./')) {
195-
finalPathName = pathName.substring(2);
196-
}
197-
198-
const activeFile = this.app.workspace.getActiveFile();
199-
if (!activeFile || !activeFile.parent) {
200-
throw new Error("No active file found");
196+
pathName = pathName.substring(2);
197+
const activeFile = this.app.workspace.getActiveFile();
198+
if (!activeFile || !activeFile.parent) {
199+
throw new Error("No active file found");
200+
}
201+
const parentPath = activeFile.parent.path;
202+
return {resolvedPath: path.join(parentPath, pathName), name: pathName};
203+
} else {
204+
return {resolvedPath: pathName, name: pathName};
201205
}
202-
203-
const parentPath = activeFile.parent.path;
204-
return {resolvedPath: path.join(parentPath, finalPathName), name: finalPathName};
205206
}
206207

207208
private getValue(): string {

0 commit comments

Comments
 (0)