I am developing a Twitter application which references to the images directly from Twitter. How can I prevent animated gifs from being played?
Using window.stop()
at the end of the page does not work for me in Firefox.
Is there a better JavaScript hack? Preferable this should work for all browsers
js installed, it's time to start controlling the GIF. Here's how you can pause a GIF then play on command — just add the freezeframe class (or a custom selector) to the GIFs you'd like control over. It's that easy! That's it!
If you want to stop animated GIFs forever: Go to Internet Options (via the Tools menu "gear" at the upper right) Select the Advanced tab. Scroll down to Multimedia to uncheck "Play animations in web pages."
The next time you're tired of seeing a GIF on a webpage just hit Esc on your keyboard and the GIF stops. This includes every GIF on a webpage. Even a page filled with animated GIFs, like Giphy, will stop with one key press. Hit Esc again and the GIFs start moving again.
Go to the Window tab and select timeline(if the timeline is not already open). At the bottom of the timeline panel, you will find an option, which says "Forever". Change that to "Once". Go to File> Export> Export for Web and save it as a gif.
Inspired by the answer of @Karussell I wrote Gifffer. Check it out here https://github.com/krasimir/gifffer
It automatically adds stop/play control on top of your Gif.
This is not a cross browser solution but this worked in firefox and opera (not in ie8 :-/). Taken from here
[].slice.apply(document.images).filter(is_gif_image).map(freeze_gif); function is_gif_image(i) { return /^(?!data:).*\.gif/i.test(i.src); } function freeze_gif(i) { var c = document.createElement('canvas'); var w = c.width = i.width; var h = c.height = i.height; c.getContext('2d').drawImage(i, 0, 0, w, h); try { i.src = c.toDataURL("image/gif"); // if possible, retain all css aspects } catch(e) { // cross-domain -- mimic original with all its tag attributes for (var j = 0, a; a = i.attributes[j]; j++) c.setAttribute(a.name, a.value); i.parentNode.replaceChild(c, i); } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With