Created
March 27, 2014 21:58
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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