Skip to content

Commit 60cf917

Browse files
committed
fix: Image src is not correct if replace media links is disabled.
1 parent 98258bc commit 60cf917

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

src/abstract-wp-client.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,10 @@ export abstract class AbstractWordPressClient implements WordPressClient {
135135
auth,
136136
postParams
137137
});
138+
const html = AppState.getInstance().markdownParser.render(postParams.content);
138139
const result = await this.publish(
139140
postParams.title ?? 'A post from Obsidian!',
140-
AppState.getInstance().markdownParser.render(postParams.content) ?? '',
141+
html,
141142
postParams,
142143
auth);
143144
if (result.code === WordPressClientReturnCode.Error) {
@@ -223,9 +224,7 @@ export abstract class AbstractWordPressClient implements WordPressClient {
223224
content: content
224225
}, auth);
225226
if (result.code === WordPressClientReturnCode.OK) {
226-
if (this.plugin.settings.replaceMediaLinks) {
227-
postParams.content = postParams.content.replace(img.original, `![${imgFile.name}](${result.data.url})`);
228-
}
227+
postParams.content = postParams.content.replace(img.original, `![${imgFile.name}](${result.data.url})`);
229228
} else {
230229
if (result.error.code === WordPressClientReturnCode.ServerInternalError) {
231230
new Notice(result.error.message, ERROR_NOTICE_TIMEOUT);
@@ -236,11 +235,13 @@ export abstract class AbstractWordPressClient implements WordPressClient {
236235
}
237236
}
238237
}
239-
activeEditor.editor.setValue(postParams.content);
240238
} else {
241239
// src is a url, skip uploading
242240
}
243241
}
242+
if (this.plugin.settings.replaceMediaLinks) {
243+
activeEditor.editor.setValue(postParams.content);
244+
}
244245
}
245246
}
246247

0 commit comments

Comments
 (0)