File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 ) ;
You can’t perform that action at this time.
0 commit comments