How to embed Gfycat in WordPress Posts


UPDATE: I rolled it into a plugin and added a couple options for playback Now you don’t have to copy paste my code! Though if you don’t care about the options, just throw the function below into your theme’s functions.php

So Gfycat, the popular GIF shrinking and video hosting service finally implemented oembed. Unfortunately, it’s not quite to spec so you can’t add it as an oembed provider to your WordPress site. But using their oembed implementation and reverse engineering their iframe embed option using their API, I was able to create this function to add gfycat embed support

Update: I changed the function to use their API instead of cludging together their oembed and iframe stuff, so it makes 1 remote call instead of 2. (and trimmed off 9 lines of code!)


Add this code to your theme’s functions.php file. I also included, but commented out the function necessary to add them as an oembed provider. If they fix their oembed implementation, simply uncomment line one, and comment out line 3.

Right now the function resizes the video to be no larger than 702px wide, simply change $max_width on line 22 to whatever you want your maximum width to be, otherwise embeded gfycats will get cut off or break your theme.