M-Reimer / toggleanigif

GNU General Public License v3.0
16 stars 1 forks source link

Freezes animated gif, but not when linked from a <figure srcset>-tag on the Wikipedia. #17

Closed tttom closed 1 month ago

tttom commented 1 month ago

This Add-on is a great idea. Animated GIF, even informative ones, make it hard for me to read the surrounding text. https://upload.wikimedia.org/wikipedia/commons/thumb/d/d2/Indeterminacy_principle.gif/360px-Indeterminacy_principle.gif freezes correctly, yet https://en.wikipedia.org/wiki/Mott_problem does not seem to do anything when clicking "Freeze" in the context menu for the above-linked gif.

I suspect that this has something to do with how it is linked from the Wikipedia:

<figure class="mw-default-size mw-halign-left" typeof="mw:File/Thumb"><a href="[/wiki/File:Indeterminacy_principle.gif](view-source:https://en.wikipedia.org/wiki/File:Indeterminacy_principle.gif)" class="mw-file-description"><img src="[//upload.wikimedia.org/wikipedia/commons/thumb/d/d2/Indeterminacy_principle.gif/180px-Indeterminacy_principle.gif](view-source:https://upload.wikimedia.org/wikipedia/commons/thumb/d/d2/Indeterminacy_principle.gif/180px-Indeterminacy_principle.gif)" decoding="async" width="180" height="135" class="mw-file-element" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/d/d2/Indeterminacy_principle.gif/270px-Indeterminacy_principle.gif 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/d/d2/Indeterminacy_principle.gif/360px-Indeterminacy_principle.gif 2x" data-file-width="640" data-file-height="480" /></a><figcaption>Spherical wave</figcaption></figure>

Environment: Firefox 121.0.1 (64-bit) on Linux version 6.2.0-39-generic (buildd@bos03-amd64-014) (x86_64-linux-gnu-gcc-12 (Ubuntu 12.3.0-1ubuntu1~23.04) 12.3.0, GNU ld (GNU Binutils for Ubuntu) 2.40) #40-Ubuntu SMP PREEMPT_DYNAMIC Tue Nov 14 14:18:00 UTC 2023 and KDE.

M-Reimer commented 1 month ago

Just tried it and for me it worked right away. Can you try again? Maybe after reloading the page?

tttom commented 1 month ago

Thanks for checking. I just rebooted, switched off all other Add-ons, but could still not get gifs to freeze on Wikipedia.

However, in the mean time I did find two ways in which the Freeze context menu does work:

  1. Download the webpage (Save As... context menu) and load it locally (file:///...)
  2. Use the Tranquility! Reader Add-on

Another example is the first image on the right on: https://en.wikipedia.org/wiki/GIF doesn't freeze. https://upload.wikimedia.org/wikipedia/commons/2/2c/Rotating_earth_%28large%29.gif does freeze.

M-Reimer commented 1 month ago

https://en.wikipedia.org/wiki/GIF doesn't freeze.

Tried with exactly this image and it freezes for me.

But your Firefox version seems to be pretty old. I'm using: Mozilla/5.0 (X11; Linux x86_64; rv:126.0) Gecko/20100101 Firefox/126.0 Can you please try with the latest version? If there are no other ways for Ubuntu, then you can always download a official build from Mozilla from their FTP and just run the "firefox" binary in there: https://ftp.mozilla.org/pub/firefox/releases/126.0/linux-x86_64/en-US/

The URL of the image, or how it is constructed, actually doesn't matter here as my Add-on does not download the image. If you click "Freeze" in the context menu, then Firefox communicates some identifier to a content script in my Add-on which is then used to get access to the \<img> object directly. Then a method in this object is called to ask for the current image representation displayed inside it. This static image then is placed to the \<img> object as its new image to display.

tttom commented 1 month ago

Thanks a lot! Version 121 was the latest on my distro, but the latest and greatest, 126.0 (64-bit), did the trick! Excellent!

M-Reimer commented 1 month ago

Thanks for checking.