You are here

function emfield_content_generate in Embedded Media Field 6

Same name and namespace in other branches
  1. 6.3 deprecated/emfield-deprecated.inc \emfield_content_generate()
  2. 6.2 emfield.module \emfield_content_generate()

Implementation of Devel module's hook_content_generate().

File

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

Code

function emfield_content_generate($node, $field) {
  $item = $urls = array();
  $module = $field['module'];
  foreach (emfield_allowed_providers($field, $module) as $provider) {
    $provider_urls = emfield_include_invoke($module, $provider->name, 'content_generate', $node, $field);
    if (is_array($provider_urls)) {
      $urls[$provider->name] = $provider_urls;
    }
  }
  if (!empty($urls)) {
    $provider = array_rand($urls);
    $item['provider'] = $provider;
    $key = array_rand($urls[$provider]);
    $item['embed'] = $urls[$provider][$key];
    $item = _emfield_field_submit_id($field, $item, $module);
  }
  return $item;
}