You are here

function emfield_parse_embed in Embedded Media Field 6

Same name and namespace in other branches
  1. 5 emfield.module \emfield_parse_embed()
  2. 6.3 deprecated/emfield-deprecated.inc \emfield_parse_embed()
  3. 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 ./emfield.module
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 ./emfield.module
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

./emfield.module, line 145
Embedded Media Field is a CCK-based framework for 3rd party media files.

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();
}