@@ -181,27 +181,28 @@ export default class ImageTagProcessor {
181181 }
182182
183183 private resolveImagePath ( imageName : string ) : ResolvedImagePath {
184- const pathName = imageName . endsWith ( '.excalidraw' ) ?
184+ let pathName = imageName . endsWith ( '.excalidraw' ) ?
185185 imageName + '.png' :
186186 imageName ;
187-
188- const imagePath = path . join ( this . settings . attachmentLocation , pathName ) ;
189- if ( this . app . vault . getAbstractFileByPath ( normalizePath ( imagePath ) ) != null ) {
190- return { resolvedPath : imagePath , name : pathName } ;
187+
188+ if ( imageName . indexOf ( '/' ) < 0 ) {
189+ pathName = path . join ( this . app . vault . config . attachmentFolderPath , pathName ) ;
190+ if ( this . app . vault . config . attachmentFolderPath . startsWith ( '.' ) ) {
191+ pathName = './' + pathName ;
192+ }
191193 }
192-
193- let finalPathName = pathName ;
194+
194195 if ( pathName . startsWith ( './' ) ) {
195- finalPathName = pathName . substring ( 2 ) ;
196- }
197-
198- const activeFile = this . app . workspace . getActiveFile ( ) ;
199- if ( ! activeFile || ! activeFile . parent ) {
200- throw new Error ( "No active file found" ) ;
196+ pathName = pathName . substring ( 2 ) ;
197+ const activeFile = this . app . workspace . getActiveFile ( ) ;
198+ if ( ! activeFile || ! activeFile . parent ) {
199+ throw new Error ( "No active file found" ) ;
200+ }
201+ const parentPath = activeFile . parent . path ;
202+ return { resolvedPath : path . join ( parentPath , pathName ) , name : pathName } ;
203+ } else {
204+ return { resolvedPath : pathName , name : pathName } ;
201205 }
202-
203- const parentPath = activeFile . parent . path ;
204- return { resolvedPath : path . join ( parentPath , finalPathName ) , name : finalPathName } ;
205206 }
206207
207208 private getValue ( ) : string {
0 commit comments