gifPlayer is a jQuery plugin that implements “player” functionality for animated GIF’s. Initially it was developed for http://svalko.org, where it had reduced the outgoing traffic by 70Gb/day.
- Loads GIF on demand.
- Start/Stop buttons.
- Fullscreen mode.
- Fully-customizable look.
- Ability to control player using special jQuery events.
jQuery 1.5 and later
Download and include the following files into your project:
js/release/jquery.gif-player.js (or js/release/jquery.gif-player.min.js) css/gif-player.css images/*
<a href="PATH_TO_ANIMATED.GIF" class="gif-player">
<img src="PREVIEW.GIF" width="320" height="320" />
</a>
<script>
$('.gif-player').gifPlayer();
</script>
You can also pass additional parameters to plugin. All parameters are optional, default values are quoted in curly braces.
url {null}
— Path to animated GIF. If omitted, the element’shref
attribute will be used instead.fullscreen {false}
— Start player in fullscreen mode.preload {false}
— Start loading GIF immediately.play {false}
— Play GIF immediately.
controlsTemplate {'<span class="gp-controls"><span class="gp-play"/><span class="gp-fullscreen"/></span>'}
— HTML-template of the player’s control panel. This HTML-code will be inserted into gif-player’s element.playControlClass {'gp-play'}
— Class name of the ‘Play/Stop’ button.fullscreenControlClass {'gp-fullscreen'}
— Class name of the ‘toggle fullscreen’ button.
loadingClass {'gp-loading'}
— Class reflecting the ‘loading’ state.playingClass {'gp-playing'}
— Class reflecting the ‘playing’ state.fullscreenClass {'gp-full'}
— Class reflecting the ‘fullscreen’ state.horizontalClass {'gp-horizontal'}
— This class is set if the animated GIF takes 100% of screen width in fullscreen mode.verticalClass {'gp-vertical'}
— This class is set if the animated GIF takes 100% of screen height in fullscreen mode.
You can also control gif-player by triggering the following events:
playGif
— Toggle playing.loadGif
— Start loading gif.fscreenGif
— Toggle fullscreen mode.
Copyright © 2011 Vladimir Zhuravlev
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.