You are here

function emfield_emfield_field_formatter in Embedded Media Field 6

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

Format our field for display. This is actually called originally by each helper module that implements hook_field_formatter, which then call this.

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, then let it embed the video.

File

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

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 (isset($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'];
  }

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

  // The individual modules actually define the theme for the formatter.
  $output = '';
  $output .= theme($module . '_' . $formatter, $field, $item, $formatter, $node, $options);
  return $output;
}