File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -557,10 +557,16 @@ export default class ContextManager {
557557 if ( elements [ i ] . type == "image_url" && elements [ i ] . image_url ?. url && ! elements [ i ] . image_url . url . startsWith ( "http" ) ) {
558558 // @ts -ignore
559559 const path = elements [ i ] . image_url ?. url ;
560-
561- const tfile = await this . app . vault . getFileByPath ( path ) ;
562-
563- if ( ! tfile ) continue ;
560+ const attachmentFolderPath = this . app . vault . getConfig ( "attachmentFolderPath" ) ; // it works to getConfig in obsidian v1.6.5
561+ console . log ( path , attachmentFolderPath )
562+
563+ let tfile = await this . app . vault . getFileByPath ( path ) ;
564+ if ( ! tfile ) {
565+ // try to find in attachment folder, base user's preferences
566+ tfile = await this . app . vault . getFileByPath ( attachmentFolderPath + "/" + path ) ;
567+ if ( ! tfile ) continue ;
568+ }
569+
564570 const mimtype = mime . lookup ( tfile . extension ) || ""
565571
566572 const buff = convertArrayBufferToBase64Link ( await this . app . vault . readBinary ( tfile as any ) , mimtype )
You can’t perform that action at this time.
0 commit comments