How to exclude images from search results

Search results show BASE64 encoded text for pasted images

I want to exclude them from my search results to make it easier to use search.

Things I have tried

I tried putting this regex in my excluded files section but it doesn’t exclude files. Any ideas?


What I’m trying to do

Search using Obsidian native search, and have an uncluttered list of search results.

1 Like

The Obsidian help section on search operators suggests that you can use -file:.png to exclude all PNG files from your search. I was able to confirm that worked with different file extensions in my vault.

*.png or **.png for ones in folders might work in the Excluded Files settings section but I’m not as fluent in that syntax.


Thank you, but that does not seem to exclude the BASE64 encoded filename from the file:

Ah, i think I missed the “pasted” aspect of the images before. My apologies! You will not be able to exclude those in “Excluded Files” since that works on folder and note names, not note content. Search query operators like line:(...) work on note contents. Have you tried using - in the search bar - something like -line(data:image/png.base64) along with your query?
One thing I don’t know with the above suggestion is what the behavior will be if you have somewhere in your file your search term and somewhere else in your file an image. I think perhaps they will be excluded too, and I am not sure off the top of my head a way around this. The link I posted previously has documentation that may help.

Another idea would be - if your query is a word that you expect to have spaces around it to add the spaces around the query e.g. " API ", since there do not seem to be spaces in the base64 encoding. This might get complicated quickly if instead of a space you expect a linebreak or punctuation though. Maybe @I-d-as has a regular expression that could help here? Also pinging @CawlinTeffid for another search question. Hopefully someone can find a solution!


@scholarInTraining Thanks for the thought. I appreciate the challenge, and would be happy to help the best I can. I am wondering whether it might help to isolate all of these images and all the notes that have the base64 encoding within a note and image subfolder with a single folder that you can completely exclude without the need for any regex. Then, within notes where you want to embed one of the encoded images, you could instead just embed one of the notes from that excluded folder which itself has an embedded encoded image within it. This way you aren’t getting what appear to be coincidental matches of certain sequences of characters if I am understanding correctly. It appears that search matched “api” 245 times within that note where you have some of these images. So by creating a layer of separation, perhaps this could be avoided.

I am also wondering whether there might be an issue with the regex that was used. Maybe @megadiddly could provide a screenshot so we could better check what is or isn’t working correctly.

Good luck!


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