Skip to content

Commit 6b97a4a

Browse files
committed
handles correctly all images
1 parent 7c5c054 commit 6b97a4a

1 file changed

Lines changed: 11 additions & 12 deletions

File tree

src/abstract-wp-client.ts

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -203,18 +203,17 @@ export abstract class AbstractWordPressClient implements WordPressClient {
203203
const images = getImages(postParams.content);
204204
for (const img of images) {
205205
if (!img.srcIsUrl) {
206-
const splitFile = img.src.split('.');
207-
const ext = splitFile.pop();
208-
const fileName = splitFile.join('.');
209-
// @ts-expect-error
210-
let filePath = (await this.plugin.app.vault.getAvailablePathForAttachments(
211-
fileName,
212-
ext,
213-
activeFile
214-
)) as string;
215-
const pathRegex = /(.*) \d+\.(.*)/;
216-
filePath = filePath.replace(pathRegex, '$1.$2');
217-
const imgFile = this.plugin.app.vault.getAbstractFileByPath(filePath);
206+
207+
img.src = decodeURI(img.src);
208+
const fileName = img.src.split("/").pop();
209+
210+
if ( fileName === undefined )
211+
continue;
212+
213+
let normPath = this.plugin.app.metadataCache.getFirstLinkpathDest(img.src, fileName);
214+
215+
const imgFile = normPath;
216+
218217
if (imgFile instanceof TFile) {
219218
const content = await this.plugin.app.vault.readBinary(imgFile);
220219
const fileType = fileTypeChecker.detectFile(content);

0 commit comments

Comments
 (0)