You are here

function emfield_emfield_field_formatter in Embedded Media Field 5

Same name and namespace in other branches
  1. 6.3 deprecated/emfield-deprecated.inc \emfield_emfield_field_formatter()
  2. 6 emfield.module \emfield_emfield_field_formatter()
  3. 6.2 emfield.module \emfield_emfield_field_formatter()
1 call to emfield_emfield_field_formatter()
_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 316

Code

function emfield_emfield_field_formatter($field, $item, $formatter, $node, $module, $options = array()) {

  // if we're coming from a preview, we need to extract our new embedded value...
  if ($node->in_preview) {
    $item = emfield_parse_embed($field, $item['embed'], $module);
  }

  // if we have no value, then return an empty string
  if (!isset($item['value'])) {
    return '';
  }

  // unfortunately, when we come from a view, we don't get all the widget fields
  if (!$node->type) {
    $type = content_types($field['type_name']);
    $field['widget'] = $type['fields'][$field['field_name']]['widget'];
  }

  // and sometimes our data is still unserialized, again from views
  if (!is_array($item['data'])) {
    $item['data'] = (array) unserialize($item['data']);
  }

  //  $module = $field['widget']['helper_module'];
  $output .= theme($module . '_' . $formatter, $field, $item, $formatter, $node, $options);
  return $output;
}