Change Default Drag and Drop Embed Behaviour?

What I’m trying to do

I am trying to change the default behaviour for when I drag and drop a file onto an Obsidian note from my computer. Specifically, I would like for new files to be inserted as text links rather than embeds.

Currently, when I drag a file from my computer onto a note, a few things happen:

  1. The file is treated as an attachment and copied into an Attachments subdirectory of the current folder.
  2. In my document, a link is generated of the format: ![[filename.pdf]] (the exclamation mark triggering the live preview/embed).

I would like the file to be moved into the Attachments subdirectory but for the link instead to be generated as [filename](filename.pdf) (no exclamation mark, and placeholder text for display).

Things I have tried

I have tried searching the forum and the community packages for something that would accomplish this but have been unable to find anything yet.

I think achieving it would be very difficult. Your question is very specific meaning you have to use some of the power plugins that can do many things.

 

In Templater you have tp.system.clipboard() but files are not supported.
https://silentvoid13.github.io/Templater/internal-functions/internal-modules/system-module.html#tpsystemclipboard

 

In QuickAdd you have quickAddApi.utility.getClipboard() but I doubt it supports files.

const clipboardText = await quickAddApi.utility.getClipboard();
console.log("Clipboard contains:", clipboardText);

https://quickadd.obsidian.guide/docs/QuickAddAPI#getclipboard-promisestring

 

And lastly you have Shell commands plugin which offer {{clipboard}}. Support for files is very limited.
https://publish.obsidian.md/shellcommands/Variables/{{clipboard}}

 

If you can for example retrieve file path from {{clipboard}} then you can use other shell commands to move files to your vault and then return the customized link.

You can also monitor files created in your vault if you drag and drop them into files:
https://publish.obsidian.md/shellcommands/Events/File+created

With some custom code in Shell commands you could then insert file links in active note (or clipboard) if their file extension is pdf (etc).

 

And very finally there is Linter which can do many powerful things maybe including solving your use case.
https://platers.github.io/obsidian-linter/settings/custom-rules/

 


I came up with some other solution not featuring any plugins:

  1. Disable wikilinks:
  2. Drag and drop your file to Files (left side bar)
  3. Go to your active note and write [[ and select your file either using down arrow ↓ and enter or left click

You can use this feature to reveal current folder:

And there is command Focus on last note if you want to reveal last active note.

1 Like

Thanks for the ideas! I honestly didn’t realize it would be this complex of an ask. While it isn’t exactly what I was hoping for (really wanted just to be able to drag and drop the file in without the ! mark), I’ve found a decent workaround is to switch to the Source Editing View prior to pulling the file in, which allows me to delete the exclamation mark without having to navigate around the embed preview.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.