function youtube_get_video_id in YouTube Field 7
Same name and namespace in other branches
- 8 youtube.module \youtube_get_video_id()
Extracts the video_id from the submitted field value.
Parameters
string $input: The input submitted to the field.
Return value
string|bool Returns the video_id if available, or FALSE if not.
4 calls to youtube_get_video_id()
- MigrateYoutubeFieldHandler::prepare in ./
youtube.migrate.inc - Converts incoming data to the proper format for YouTube fields.
- youtube_field_validate in ./
youtube.module - Implements hook_field_validate().
- youtube_input_validate in ./
youtube.module - Validation for YouTube fields.
- youtube_set_target in ./
youtube.inc - Callback to set the Feeds target for a YouTube field.
File
- ./
youtube.inc, line 17 - YouTube field helper functions.
Code
function youtube_get_video_id($input) {
// See README.txt for accepted URL formats.
preg_match("/^(?:http(?:s)?:\\/\\/)?(?:www\\.)?(?:youtu\\.be\\/|youtube\\.com\\/(?:(?:watch)?\\?(?:.*&)?v(?:i)?=|(?:embed|v|vi|user)\\/))([^\\?&\"'<> #]+)/", $input, $matches);
if (!empty($matches[1])) {
$video_id = $matches[1];
return $video_id;
}
return FALSE;
}