function emfield_parse_embed in Embedded Media Field 5
Same name and namespace in other branches
- 6.3 deprecated/emfield-deprecated.inc \emfield_parse_embed()
- 6 emfield.module \emfield_parse_embed()
- 6.2 emfield.module \emfield_parse_embed()
This will parse the url or embedded code pasted by the node submitter. returns either an empty array (if no match), or an array of provider and value.
3 calls to emfield_parse_embed()
- emfield_emfield_field_formatter in ./
emfield.module - _emfield_field_submit_id in ./
emfield.module - replace embedded code with the extracted id. this goes in the field 'value' also allows you to grab directly from the URL to display the content from field 'provider'
- _eminline_url_parse_full_links in contrib/
eminline/ eminline.module - If one of our allowed providers knows what to do with the url let them embedd the video.
File
- ./
emfield.module, line 267
Code
function emfield_parse_embed($field, $embed = '', $module) {
// if ($embed) {
// $module = $field['widget']['helper_module'];
$providers = emfield_allowed_providers($field, $module);
foreach ($providers as $provider) {
$success = emfield_include_invoke($module, $provider->name, 'extract', trim($embed), $field);
// we've been given an array of regex strings, so let's see if we can find a match
if (is_array($success)) {
foreach ($success as $regex) {
$matches = NULL;
if (preg_match($regex, trim($embed), $matches)) {
return array(
'provider' => $provider->name,
'value' => $matches[1],
);
}
}
}
else {
if ($success) {
return array(
'provider' => $provider->name,
'value' => $success,
);
}
}
}
// }
// we found no match
return array();
}