Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Possible to load an animated gif without playing the animation?

I wonder if there is a way to prevent a browser from actually animating an animated gif, loaded in a <img> tag. I just want it to display the first frame of the gif and don't play the animation.

I already fear that this isn't possible and I have to extract the first frame and render it to a canvas... :/

like image 563
Christian Engel Avatar asked Nov 14 '13 22:11

Christian Engel


1 Answers

This is kinda an expensive solution, but if you reset image SRC on a very short setInterval it appears as static e.g:

setInterval(function() {
       document.getElementById('img1').src = document.getElementById('img1').src
},1)

Demo: http://jsfiddle.net/MEaWP/6/

like image 176
Yuriy Galanter Avatar answered Sep 28 '22 05:09

Yuriy Galanter