{"id":38143,"date":"2017-09-28T18:01:21","date_gmt":"2017-09-28T10:01:21","guid":{"rendered":"https:\/\/www.hongkiat.com\/blog\/?p=38143"},"modified":"2017-11-26T01:40:02","modified_gmt":"2017-11-25T17:40:02","slug":"facebook-style-animated-gif-embed","status":"publish","type":"post","link":"https:\/\/www.hongkiat.com\/blog\/facebook-style-animated-gif-embed\/","title":{"rendered":"Embed Animated GIFs Like Facebook with jqGifPreview"},"content":{"rendered":"<p>Twitter and Facebook have a lot of people <strong>sharing animated GIFs<\/strong> daily. If these are all auto-played they could be gruesome <a href=\"https:\/\/www.hongkiat.com\/blog\/facebook-news-feed-design\/\">in a feed<\/a>.<\/p>\n<p>Both networks get around this with a <strong>click-to-preview feature<\/strong> for all GIFs. This lets the user choose <strong>which animations they want to see<\/strong> by choosing when to start\/stop the animation.<\/p>\n<p>With the <strong><a href=\"https:\/\/github.com\/SodhanaLibrary\/jqGifPreview\" target=\"_blank\">jqGifPreview plugin<\/a><\/strong>, you can bring this same functionality to your website.<\/p>\n<p>This <strong>free jQuery plugin<\/strong> works on all GIFs on the page, or can specifically target any that you want. It\u2019s a fantastic resource but does take a little while to set up.<\/p>\n<p>A paused GIF is really just <strong>one frame of the animation<\/strong>, displayed on the page.<\/p>\n<p>Unfortunately, this plugin <strong><em>does not<\/em> automatically pull a static pic from the GIF<\/strong> for you. But, you can accomplish this <a href=\"https:\/\/stackoverflow.com\/a\/3380246\" target=\"_blank\">using PHP<\/a> or any other backend language, so with a bit of code, this can be automated.<\/p>\n<p class=\"note\"><strong>Read Also:<\/strong> <a target=\"_blank\" href=\"https:\/\/www.hongkiat.com\/blog\/websites-to-create-animated-gifs\/\">10 Sites to Create Animated GIFs for Free<\/a><\/p>\n<p>This plugin uses a <a href=\"https:\/\/www.hongkiat.com\/blog\/better-ux-html-data-attributes\/\">data-* attribute<\/a> to <strong>store the GIF image location<\/strong>. Once the user clicks the image, it\u2019ll automatically load into the <code>src<\/code> attribute of the image and be displayed on the screen.<\/p>\n<p>Simple, effective, and definitely a neat effect! All you need is the CSS\/JS files for this plugin that you can <strong><a href=\"https:\/\/github.com\/SodhanaLibrary\/jqGifPreview\" target=\"_blank\">pull directly from GitHub<\/a><\/strong>. And of course, you\u2019ll <strong>need a copy of jQuery<\/strong>, too.<\/p>\n<p>From there, you set up your image like this:<\/p>\n<pre>\r\n&lt;img class=\"myImg\" src=\"sample_first_frame.png\"\r\ndata-gif=\"sample_giphy.gif\"&gt;\r\n<\/pre>\n<p>The main <code>src<\/code> attribute should <strong>contain the static picture<\/strong>. You can either build a script to generate it, or you can manually edit & upload a static shot for each GIF.<\/p>\n<p>The <code>data-gif<\/code> attribute <strong>holds the real animated GIF<\/strong> and they\u2019ll swap on click if you <strong>target the main image class<\/strong> (in this case, it\u2019s <code>.myImg<\/code>). Now, all you need is one line of jQuery to get it all working:<\/p>\n<pre>\r\n$(\".myImg\").jqGifPreview();\r\n<\/pre>\n<p>Definitely, one of the coolest jQuery plugins I\u2019ve seen this month and it\u2019s pretty easy to set up.<\/p>\n<p>You can learn more by visiting the <strong><a href=\"https:\/\/github.com\/SodhanaLibrary\/jqGifPreview\" target=\"_blank\">GitHub page<\/a><\/strong> and there\u2019s also a <strong><a href=\"http:\/\/demo.sodhanalibrary.com\/angular\/gif_preview\/jqGifPreview\/demo.html\" target=\"_blank\">live demo preview<\/a><\/strong> hosted on the developer\u2019s website.<\/p>\n<p class=\"note\"><strong>Read Also:<\/strong> <a target=\"_blank\" href=\"https:\/\/www.hongkiat.com\/blog\/gif-makers-editors-ios\/\">13 Best iOS Apps to Create and Edit GIFs<\/a><\/p>","protected":false},"excerpt":{"rendered":"<p>Twitter and Facebook have a lot of people sharing animated GIFs daily. If these are all auto-played they could be gruesome in a feed. Both networks get around this with a click-to-preview feature for all GIFs. This lets the user choose which animations they want to see by choosing when to start\/stop the animation. With&hellip;<\/p>\n","protected":false},"author":18,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[3395],"tags":[3686],"topic":[4520],"class_list":["entry-content","is-maxi"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v22.8 (Yoast SEO v27.9) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>How to Embed Animated GIFs Like Facebook<\/title>\n<meta name=\"description\" content=\"Twitter and Facebook have a lot of people sharing animated GIFs daily. If these are all auto-played they could be gruesome in a feed. Both networks get\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.hongkiat.com\/blog\/facebook-style-animated-gif-embed\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Embed Animated GIFs Like Facebook with jqGifPreview\" \/>\n<meta property=\"og:description\" content=\"Twitter and Facebook have a lot of people sharing animated GIFs daily. If these are all auto-played they could be gruesome in a feed. Both networks get\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.hongkiat.com\/blog\/facebook-style-animated-gif-embed\/\" \/>\n<meta property=\"og:site_name\" content=\"Hongkiat\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/hongkiatcom\" \/>\n<meta property=\"article:published_time\" content=\"2017-09-28T10:01:21+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-11-25T17:40:02+00:00\" \/>\n<meta name=\"author\" content=\"Jake Rocheleau\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@hongkiat\" \/>\n<meta name=\"twitter:site\" content=\"@hongkiat\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jake Rocheleau\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/facebook-style-animated-gif-embed\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/facebook-style-animated-gif-embed\\\/\"},\"author\":{\"name\":\"Jake Rocheleau\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/person\\\/966b2daea15283b4145e71aa98a82c2a\"},\"headline\":\"Embed Animated GIFs Like Facebook with jqGifPreview\",\"datePublished\":\"2017-09-28T10:01:21+00:00\",\"dateModified\":\"2017-11-25T17:40:02+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/facebook-style-animated-gif-embed\\\/\"},\"wordCount\":370,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\"},\"keywords\":[\"Animated GIFs\"],\"articleSection\":[\"UI\\\/UX\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/facebook-style-animated-gif-embed\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/facebook-style-animated-gif-embed\\\/\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/facebook-style-animated-gif-embed\\\/\",\"name\":\"How to Embed Animated GIFs Like Facebook\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#website\"},\"datePublished\":\"2017-09-28T10:01:21+00:00\",\"dateModified\":\"2017-11-25T17:40:02+00:00\",\"description\":\"Twitter and Facebook have a lot of people sharing animated GIFs daily. If these are all auto-played they could be gruesome in a feed. Both networks get\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/facebook-style-animated-gif-embed\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/facebook-style-animated-gif-embed\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/facebook-style-animated-gif-embed\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Embed Animated GIFs Like Facebook with jqGifPreview\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\",\"name\":\"Hongkiat\",\"description\":\"Tech and Design Tips\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\",\"name\":\"Hongkiat.com\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wp-content\\\/uploads\\\/hkdc-logo-rect-yoast.jpg\",\"contentUrl\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wp-content\\\/uploads\\\/hkdc-logo-rect-yoast.jpg\",\"width\":1200,\"height\":799,\"caption\":\"Hongkiat.com\"},\"image\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/hongkiatcom\",\"https:\\\/\\\/x.com\\\/hongkiat\",\"https:\\\/\\\/www.pinterest.com\\\/hongkiat\\\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/person\\\/966b2daea15283b4145e71aa98a82c2a\",\"name\":\"Jake Rocheleau\",\"description\":\"Jake is a writer and designer with over 10 years experience working on the web. He writes about user experience design and cool resources for designers\",\"sameAs\":[\"https:\\\/\\\/www.hongkiat.com\"],\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/author\\\/jake\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"How to Embed Animated GIFs Like Facebook","description":"Twitter and Facebook have a lot of people sharing animated GIFs daily. If these are all auto-played they could be gruesome in a feed. Both networks get","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.hongkiat.com\/blog\/facebook-style-animated-gif-embed\/","og_locale":"en_US","og_type":"article","og_title":"Embed Animated GIFs Like Facebook with jqGifPreview","og_description":"Twitter and Facebook have a lot of people sharing animated GIFs daily. If these are all auto-played they could be gruesome in a feed. Both networks get","og_url":"https:\/\/www.hongkiat.com\/blog\/facebook-style-animated-gif-embed\/","og_site_name":"Hongkiat","article_publisher":"https:\/\/www.facebook.com\/hongkiatcom","article_published_time":"2017-09-28T10:01:21+00:00","article_modified_time":"2017-11-25T17:40:02+00:00","author":"Jake Rocheleau","twitter_card":"summary_large_image","twitter_creator":"@hongkiat","twitter_site":"@hongkiat","twitter_misc":{"Written by":"Jake Rocheleau","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.hongkiat.com\/blog\/facebook-style-animated-gif-embed\/#article","isPartOf":{"@id":"https:\/\/www.hongkiat.com\/blog\/facebook-style-animated-gif-embed\/"},"author":{"name":"Jake Rocheleau","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/person\/966b2daea15283b4145e71aa98a82c2a"},"headline":"Embed Animated GIFs Like Facebook with jqGifPreview","datePublished":"2017-09-28T10:01:21+00:00","dateModified":"2017-11-25T17:40:02+00:00","mainEntityOfPage":{"@id":"https:\/\/www.hongkiat.com\/blog\/facebook-style-animated-gif-embed\/"},"wordCount":370,"commentCount":0,"publisher":{"@id":"https:\/\/www.hongkiat.com\/blog\/#organization"},"keywords":["Animated GIFs"],"articleSection":["UI\/UX"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.hongkiat.com\/blog\/facebook-style-animated-gif-embed\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.hongkiat.com\/blog\/facebook-style-animated-gif-embed\/","url":"https:\/\/www.hongkiat.com\/blog\/facebook-style-animated-gif-embed\/","name":"How to Embed Animated GIFs Like Facebook","isPartOf":{"@id":"https:\/\/www.hongkiat.com\/blog\/#website"},"datePublished":"2017-09-28T10:01:21+00:00","dateModified":"2017-11-25T17:40:02+00:00","description":"Twitter and Facebook have a lot of people sharing animated GIFs daily. If these are all auto-played they could be gruesome in a feed. Both networks get","breadcrumb":{"@id":"https:\/\/www.hongkiat.com\/blog\/facebook-style-animated-gif-embed\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.hongkiat.com\/blog\/facebook-style-animated-gif-embed\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.hongkiat.com\/blog\/facebook-style-animated-gif-embed\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.hongkiat.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Embed Animated GIFs Like Facebook with jqGifPreview"}]},{"@type":"WebSite","@id":"https:\/\/www.hongkiat.com\/blog\/#website","url":"https:\/\/www.hongkiat.com\/blog\/","name":"Hongkiat","description":"Tech and Design Tips","publisher":{"@id":"https:\/\/www.hongkiat.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.hongkiat.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.hongkiat.com\/blog\/#organization","name":"Hongkiat.com","url":"https:\/\/www.hongkiat.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.hongkiat.com\/blog\/wp-content\/uploads\/hkdc-logo-rect-yoast.jpg","contentUrl":"https:\/\/www.hongkiat.com\/blog\/wp-content\/uploads\/hkdc-logo-rect-yoast.jpg","width":1200,"height":799,"caption":"Hongkiat.com"},"image":{"@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/hongkiatcom","https:\/\/x.com\/hongkiat","https:\/\/www.pinterest.com\/hongkiat\/"]},{"@type":"Person","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/person\/966b2daea15283b4145e71aa98a82c2a","name":"Jake Rocheleau","description":"Jake is a writer and designer with over 10 years experience working on the web. He writes about user experience design and cool resources for designers","sameAs":["https:\/\/www.hongkiat.com"],"url":"https:\/\/www.hongkiat.com\/blog\/author\/jake\/"}]}},"jetpack_featured_media_url":"https:\/\/","jetpack_shortlink":"https:\/\/wp.me\/p4uxU-9Vd","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/38143","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/users\/18"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/comments?post=38143"}],"version-history":[{"count":2,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/38143\/revisions"}],"predecessor-version":[{"id":42031,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/38143\/revisions\/42031"}],"wp:attachment":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/media?parent=38143"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/categories?post=38143"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/tags?post=38143"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/topic?post=38143"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}