在 HTML 中禁用 GIF 动画

问题描述:

在 HTML 中,有什么方法可以在 中包含动画 GIF?标签,但自动告诉 GIF 不动画?我意识到用户可以通过按 ESC 或单击停止来停止动画,但我希望 GIF 根本不动画.

Is there any way, in HTML, to include an animated GIF in an <img> tag, but automatically tell the GIF to not animate? I realize that the user can stop animation by pressing ESC or clicking Stop, but I want the GIFs not to animate at all.

我只想在一个特定页面上执行此操作,并且制作单独的(1500 多个)GIF 的非动画版本是不可行的.我只是想让 GIF 没有动画.

I only want to do this on one specific page, and making separate non-animated versions of the (1500+) GIFs is not feasible. I simply want the GIFs to not animate.

你可以使用 Giffer.

只需在您的页面中包含库:

Just include the library in your page:

<script type="text/javascript" src="gifffer.min.js"></script>

不要在图像上设置 src 属性,而是使用 data-gifffer.

Instead of setting src attribute on your image use data-gifffer.

<img data-gifffer="image.gif" />

最后,随时调用 Gifffer().例如:

At the end, call Gifffer() whenever you want. For example:

window.onload = function() {
    Gifffer();
}

如果您根本不希望 GIF 移动,您可以随时编辑 .js 文件以删除播放按钮.

If you don't want the GIF to move at all you can always edit the .js file to remove the play button.