Skip to content

Commit 2f6b6f5

Browse files
authored
Merge pull request #95 from bugparty/main
fix when publishing to wordpress, it will lose the image size info in the img tag
2 parents 9a3012a + 558c9ea commit 2f6b6f5

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
@@ -212,7 +212,13 @@ export abstract class AbstractWordPressClient implements WordPressClient {
212212
content: content
213213
}, auth);
214214
if (result.code === WordPressClientReturnCode.OK) {
215-
postParams.content = postParams.content.replace(img.original, `![${imgFile.name}](${result.data.url})`);
215+
if(img.width && img.height){
216+
postParams.content = postParams.content.replace(img.original, `![[${result.data.url}|${img.width}x${img.height}]]`);
217+
}else if (img.width){
218+
postParams.content = postParams.content.replace(img.original, `![[${result.data.url}|${img.width}]]`);
219+
}else{
220+
postParams.content = postParams.content.replace(img.original, `![[${result.data.url}]]`);
221+
}
216222
} else {
217223
if (result.error.code === WordPressClientReturnCode.ServerInternalError) {
218224
new Notice(result.error.message, ERROR_NOTICE_TIMEOUT);
@@ -250,7 +256,7 @@ export abstract class AbstractWordPressClient implements WordPressClient {
250256
// read note title, content and matter data
251257
const title = file.basename;
252258
const { content, matter: matterData } = await processFile(file, this.plugin.app);
253-
259+
254260
// check if profile selected is matched to the one in note property,
255261
// if not, ask whether to update or not
256262
await this.checkExistingProfile(matterData);

0 commit comments

Comments
 (0)