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

The same image appears twice in the file, and the second image cannot be enlarged #31

Open jiajiala opened 1 year ago

jiajiala commented 1 year ago

The same image appears twice in the file, and the second image cannot be enlarged Honeycam 2023-08-31 11-27-47

Mideks commented 8 months ago

I tried to fix this bug today, but it seems to be more difficult than I thought... :(

nicojeske commented 8 months ago

The problem is that Obsidian generates the exact same HTML nodes for each picture. Therefore we do not really - as far as I am aware - have a method to recognize which instance of the image was hovered over. In this case we fallback to only modifying the first image.

Mideks commented 8 months ago

I was trying to add a function to count identical files, and figure out which one is currently scaled. Like "take all the pictures from the document, then filter out the ones that link to the one you just clicked, then go through the generated list looking for a matching picture"

However, since files can, in theory, be attached in different formats (lol, who would even do that?), it turned out to be not as easy to do with the current implementation as I expected. Also, in addition to determining the total number of identical pictures, for the case where 2 or more pictures already have the same size set, you need to determine which one is trying to be enlarged. Which also causes difficulties, as the js only replaces the first occurrence, and doesn't allow to skip some number before it...

Ok, this seemingly simple problem turned out to be much more complicated... who would have thought. I hope my reasoning will help in solving the problem