Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Theme-based embed.ly oEmbed support for Wordpress multisite installations.
// We use embed.ly to help with oembeds that aren't very clean
// Define our API KEY
define('EMBEDLY_KEY','YOUR_KEY_HERE');
// remove default polldaddy provider because its broken
// this can be removed when WP removes support for polldaddy
// see http://core.trac.wordpress.org/ticket/24395
wp_oembed_remove_provider( '#https?://(.+\.)?polldaddy\.com/.*#i' );
$regex_patterns = file(dirname( __FILE__ ).'/embedly_patterns.def');
foreach ($regex_patterns as $regex) {
wp_oembed_add_provider($regex, 'http://api.embed.ly/1/oembed?key='.EMBEDLY_KEY, true);
}
/**
* Make oEmbed Videos Responsive
* Adapted from Responsive Video Embeds v1.1
* Uses Zurb Foundation Flex Video CSS Classes
* Only runs on things that are an iframe, object, or embed tag
* @return string
* @link http://wordpress.org/extend/plugins/responsive-video-embeds/
* @link http://www.zurb.com/article/865/responsive-video-embeds-on-all-devices
*/
function modify_embed_output( $html, $url, $attr ) {
if ((stripos($html,'<iframe') !== false || stripos($html,'<object') !== false || stripos($html,'<embed') !== false) && stripos($html,'flex-video') === false )
return '<div class="flex-video">'.$html.'</div>';
else
return $html;
}
add_filter( 'embed_oembed_html', 'modify_embed_output', 9999, 3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment