Skip to content

Instantly share code, notes, and snippets.

@PunchRockgroin
Created March 27, 2014 21:58
Show Gist options
  • Save PunchRockgroin/9819954 to your computer and use it in GitHub Desktop.
Save PunchRockgroin/9819954 to your computer and use it in GitHub Desktop.
Gumby intrinsic Video Wrapper for Wordpress oEmbed. My regex is only as strong as Google can get me.
function THEMENAME_wrap_gumby_intrinsic($html, $url, $args){
$provider = '';
if (preg_match("#https?://youtu\.be/.*#i", $url) || preg_match("#https?://(www\.)?youtube\.com/watch.*#i", $url)) {
$provider = 'youtube';
}elseif (preg_match("/vimeo.com\/([^&]+)/i", $url)) {
$provider = 'vimeo';
}
//no oEmbed for Twich :<
//elseif (preg_match("/https?:\/\/(.*twitch\.tv\/.*|.*twitch\.tv\/.*\/b\/.*)/i", $url)){
//$provider = 'twitch';
//}
$html = "<div class='video ".$provider."' >". $html . "</div>";
return $html;
}
add_filter( 'embed_oembed_html', 'THEMENAME_wrap_gumby_intrinsic', 10, 3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment