Skip to content

Commit 558c9ea

Browse files
committed
fix when publishing to wordpress, it will bypass the markdown-image-plugin and lose the image size info
1 parent 55816bc commit 558c9ea

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/abstract-wp-client.ts

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

0 commit comments

Comments
 (0)