Gfycat extension for Kirbytext

Gfycat is great for converting GIFs to quick-loading videos, but its regular embed code uses an iframe and other superfluous code. This Kirbytext extension strips it down to the native video element and a fallback .gif.

Save this file as /site/tags/gfycat.php


kirbytext::$tags['gfycat'] = array(
  	'html' => function($tag) {
    	$gfyID = $tag->attr('gfycat');

    	return '<video poster="//'.$gfyID.'-poster.jpg" loop autoplay mute>
    			<source id="webmsource" type="video/webm" src="//'.$gfyID.'.webm"></source>
    			<source id="mp4source" type="video/mp4" src="//'.$gfyID.'.mp4"></source>
    			<img src="//'.$gfyID.'.gif"></img>


Use it in your content pages like this (gfycat: ExhaustedVapidGorilla)

This code is also on GitHub