Skip to content

Commit d8789d6

Browse files
committed
fix when publishing to wordpress, it will bypass the markdown-image-plugin and lose the image size info
1 parent 7f919cf commit d8789d6

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

src/abstract-wp-client.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,13 @@ export abstract class AbstractWordPressClient implements WordPressClient {
223223
content: content
224224
}, auth);
225225
if (result.code === WordPressClientReturnCode.OK) {
226-
postParams.content = postParams.content.replace(img.original, `![${imgFile.name}](${result.data.url})`);
226+
if(img.width && img.height){
227+
postParams.content = postParams.content.replace(img.original, `![[${result.data.url}|${img.width}x${img.height}]]`);
228+
}else if (img.width){
229+
postParams.content = postParams.content.replace(img.original, `![[${result.data.url}|${img.width}]]`);
230+
}else{
231+
postParams.content = postParams.content.replace(img.original, `![[${result.data.url}]]`);
232+
}
227233
} else {
228234
if (result.error.code === WordPressClientReturnCode.ServerInternalError) {
229235
new Notice(result.error.message, ERROR_NOTICE_TIMEOUT);
@@ -261,7 +267,7 @@ export abstract class AbstractWordPressClient implements WordPressClient {
261267
// read note title, content and matter data
262268
const title = file.basename;
263269
const { content, matter: matterData } = await processFile(file, this.plugin.app);
264-
270+
265271
// check if profile selected is matched to the one in note property,
266272
// if not, ask whether to update or not
267273
await this.checkExistingProfile(matterData);

0 commit comments

Comments
 (0)