@@ -36,7 +36,7 @@ export default class ImageTagProcessor {
3636 const images = this . getImageLists ( value ) ;
3737 const uploader = this . imageUploader ;
3838 for ( const image of images ) {
39- if ( ( await this . app . vault . getAbstractFileByPath ( normalizePath ( image . path ) ) ) == null ) {
39+ if ( this . app . vault . getAbstractFileByPath ( normalizePath ( image . path ) ) == null ) {
4040 new Notice ( `Can NOT locate ${ image . name } with ${ image . path } , please check image path or attachment option in plugin setting!` , 10000 ) ;
4141 console . log ( `${ normalizePath ( image . path ) } not exist` ) ;
4242 break ;
@@ -82,13 +82,13 @@ export default class ImageTagProcessor {
8282 const mdMatches = value . matchAll ( MD_REGEX ) ;
8383 for ( const match of wikiMatches ) {
8484 const name = match [ 1 ]
85- var path_name = name
85+ let path_name = name
8686 if ( name . endsWith ( '.excalidraw' ) ) {
8787 path_name = name + '.png'
8888 }
8989 images . push ( {
9090 name : name ,
91- path : this . settings . attachmentLocation + '/' + path_name ,
91+ path : path . join ( this . settings . attachmentLocation , path_name ) ,
9292 source : match [ 0 ] ,
9393 url : '' ,
9494 } )
@@ -97,10 +97,14 @@ export default class ImageTagProcessor {
9797 if ( match [ 2 ] . startsWith ( 'http://' ) || match [ 2 ] . startsWith ( 'https://' ) ) {
9898 continue
9999 }
100- const decodedPath = decodeURI ( match [ 2 ] ) ;
100+ let decodedPath = decodeURI ( match [ 2 ] ) ;
101+ const parentPath = this . app . workspace . getActiveFile ( ) . parent . path ;
102+ if ( decodedPath . startsWith ( './' ) ) {
103+ decodedPath = decodedPath . substring ( 2 ) ;
104+ }
101105 images . push ( {
102106 name : decodedPath ,
103- path : decodedPath ,
107+ path : path . join ( parentPath , decodedPath ) ,
104108 source : match [ 0 ] ,
105109 url : '' ,
106110 } )
0 commit comments