function emfield_parse_embed in Embedded Media Field 6.3
Same name and namespace in other branches
- 5 emfield.module \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.
Return value
Either an empty array (if no match), or an array of 'provider' and 'value'.
4 calls to emfield_parse_embed()
- emfield_emfield_field_formatter in deprecated/
emfield-deprecated.inc - Format our field for display. This is actually called originally by each helper module that implements hook_field_formatter, which then call this.
- _emfield_field_submit_id in deprecated/
emfield-deprecated.inc - Replace embedded code with the extracted id. this goes in the field 'value'. This 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, then let it embed the video.
- _emthumb_formatter_theme_helper in contrib/
emthumb/ emthumb.theme.inc - Sets up the options array with the proper node, field, etc.
File
- deprecated/
emfield-deprecated.inc, line 170 - Functionality to be deprecated from earlier versions of Embedded Media Field.
Code
function emfield_parse_embed($field, $embed = '', $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 try to 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();
}