function asset_embed_youtube_extract_id in Asset 5
Same name and namespace in other branches
- 6 asset_embed/providers/youtube.inc \asset_embed_youtube_extract_id()
File
- asset_embed/
providers/ youtube.inc, line 12
Code
function asset_embed_youtube_extract_id($text) {
$matches = array();
// first try to match the embed tag
preg_match('/param[^>]*value=\\"http:\\/\\/www.youtube.com\\/v\\/([^\\"]*)\\"/', $text, $matches);
// then the URL
if (!isset($matches[1])) {
// http://youtube.com/watch?v=9193duFdUec
preg_match('/http:\\/\\/www.youtube.com\\/watch\\?v=(.*)^\\"/', $text, $matches);
}
return isset($matches[1]) ? array(
'id' => $matches[1],
) : false;
}