Handling insert attachment event

Hello everyone,

I’m currently developing a plugin to automatically manage image attachments upon insertion. While I’ve successfully handled the ‘editor-drop’ event, I’m facing a challenge with the ‘Insert Attachment’ command, particularly on mobile devices.

Despite thorough exploration of Obsidian’s API, I haven’t found a direct callback for this event. A possible workaround involves monitoring the vault’s ‘create’ event, but it introduces complexities like backlink of the attachment and the complicated logic that will be quite different from the already-implemented one.

Is there a straightforward method to monitor the ‘Insert Attachment’ event directly?

Appreciate any insights or suggestions you might have!

9 Likes

It would be very helpful if it could be achieved! Support!

There is no such an event. You can see in my plugin GitHub - RainCat1998/obsidian-custom-attachment-location: Customize attachment location with variables($filename, $data, etc) like typora.

I patch 3 places to capture all possible scenarios