GFYcat embed
#1
this can probably be improved upon, but I couldnt find this anywhere and made my own MyCode for it in a quick 10 minute session this morning.

http://gfycat.com/

Could probably expand in the future to replace all .gif's links posted with;
"gfycat.com/fetch/" before a url will automatically fetch and convert it.
eg: gfycat.com/fetch/http://mygif.myhost.com/image.gif

I think I may be able to whip a plugin up to do that but my php skills are minimal.

WHY USE IT?
gfy are far smaller than .gifs (and have some other uses)
so on gif-heavy forums you can save your members some bandwidth

Requirements;

This somewhere in the template
<script>
 (function(d, t) {
    var g = d.createElement(t),
        s = d.getElementsByTagName(t)[0];
    g.src = 'http://assets.gfycat.com/js/gfyajax-0.517d.js';
    s.parentNode.insertBefore(g, s);
}(document, 'script'));
</script>

GFYcan link example;
http://gfycat.com/SelfreliantSingleFlyinglemur

Gif Size: 4.3 MB
Gfy Size: 457.8 kB
Compression: 9.6 to 1


We only want the part after the slash, so we use;
Regular Expression;
\[gfy\]https?:\/\/?gfycat\.com\/([a-z0-9]*)\[/gfy\]

Replacement:
<img class="gfyitem" data-id="$1" />

and then this code will embed it;
[gfy]gfycat.com/SelfreliantSingleFlyinglemur[/gfy]


Any suggestions or improvements would be welcome.

edit; fixed the Expression, as it wouldnt embed anything with the http
Reply


Messages In This Thread
GFYcat embed - by p00lz - 2013-12-04, 07:42 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)