nicojeske / mousewheel-image-zoom

An Obsidian plugin that enables you to increase/decrease the size of an image by holding down a configurable key (defaults to left alt), hovering over an image in preview mode and scrolling.
MIT License
90 stars 5 forks source link

Add support for local files, even without arguments (fix #35) #41

Closed Mideks closed 8 months ago

Mideks commented 8 months ago

I think it's fix for #35 Now all of those links are correct: C:...\image.png C:...\image.png? C:...\image.png?123 file:\C:...\image.png file:\C:...\image.png? file:\C:...\image.png?123

nicojeske commented 8 months ago

Your approach handles these local files but then fails to recognize images that were embedded via the Obsidian Syntax (i.e. ![[image.jpg]]).

These image get a path ending with a query parameter e.g. app://4de8acc508e45a4cd7f12451e76d83dbb293/C:/.../image.png?1754515

Your regex includes the query part so the function would return image.png?1754515. This can then not be matched in the file as the query part is appended by obsidian.

I will add a commit with a new Regex that (hopefully) covers all cases. I think we can safely disregard the handling of query parameters for local files as ? is not allowed in filenames.

Mideks commented 8 months ago

Hmm, really missed that way of attaching files when I was testing. And I was thinking "why would a file path even have a construct with arguments...?". Turns out that's why :) Actually, I was thinking about a similar one to your regular expression, but decided to cut it down for unnecessary, huh