function _video_embed_instagram_get_video_id in Video Embed Instagram 7
Helper function to take an instagram video url and return its id.
Parameters
string $url: This is string witch user input into video field.
Return value
string|bool Return FALSE if fails to get id using regexp on user input string.
2 calls to _video_embed_instagram_get_video_id()
- video_embed_instagram_handle_thumbnail in ./
video_embed_instagram.module - Retrieve the thumbnail for the instagram video.
- video_embed_instagram_handle_video in ./
video_embed_instagram.module - This is the video handler (the 'function' key from handler_info).
File
- ./
video_embed_instagram.module, line 166 - Add a handler for instagram videos to Video Embed Field.
Code
function _video_embed_instagram_get_video_id($url) {
$output = FALSE;
$url = check_plain($url);
// Parse_url is an easy way to break a url into its components.
$matches = array();
$url = preg_replace('/\\?.*/', '', $url);
// Grab id of instagram_video to get thumbnail for it and construct proper
// iframe.
preg_match('/instagram\\.com\\/p\\/(.*)[\\/]?/', $url, $matches);
if ($matches && !empty($matches[1])) {
// If url was with '/' symbol, clear it.
$output = rtrim($matches[1], '/');
}
return $output;
}