GIF images consists of many frames, so size of GIF image is more as compared to normal image. Its not recommended to load GIF images first and its better to maintain one normal preview image for every GIF image. You can use first frame of GIF image as preview image. Click here to see my on-line tool for generating first frame of GIF image

How Facebook Handles GIF images

Facebook is not loading GIF images directly. Its converting user uploaded GIF images into simple video format. Find below inspected source code
Here We are not following facebook way of dealing GIF images. We are just loading GIF images
on user's interest

jqGifPreview

I have created this plugin, you can find it on github. Lets see how to use this plugin

Add jQuery

<script src="https://code.jquery.com/jquery-1.12.0.min.js"></script>

Add CSS and JS of jqGifPreview

<link rel="stylesheet" href="jqGifPreview/jqGifPreview.css" />
<script src="jqGifPreview/jqGifPreview.js"></script>

HTML markup

data-gif : gif image path
src : gif preview image path
<img class="myImg" src="sample_first_frame.png" data-gif="sample_giphy.gif" />

JS Code

$(function() {
    $(".myImg").jqGifPreview();
});

0 comments:

Blogroll

Follow this blog by Email

Popular Posts