Skip to content

Instantly share code, notes, and snippets.

@samnabi
Last active August 29, 2015 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samnabi/c4f023543b7ad8fe080d to your computer and use it in GitHub Desktop.
Save samnabi/c4f023543b7ad8fe080d to your computer and use it in GitHub Desktop.
Kirbytext extension for Gfycat
<?php
kirbytext::$tags['gfycat'] = array(
'html' => function($tag) {
$gfyID = $tag->attr('gfycat');
return '<video poster="//thumbs.gfycat.com/'.$gfyID.'-poster.jpg" loop autoplay mute>
<source id="webmsource" type="video/webm" src="//zippy.gfycat.com/'.$gfyID.'.webm"></source>
<source id="mp4source" type="video/mp4" src="//fat.gfycat.com/'.$gfyID.'.mp4"></source>
<img src="//giant.gfycat.com/'.$gfyID.'.gif"></img>
</video>';
}
);
?>
@samnabi
Copy link
Author

samnabi commented Aug 2, 2015

  1. Save this file as /site/tags/gfycat.php
  2. Use it in your content pages like this: (gfycat: ExhaustedVapidGorilla)

Gfycat's regular embed code uses an iframe and other superfluous code. This Kirbytext extension strips it down to the native video element.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment