You are here

function file_field_formatter_view in Drupal 7

Implements hook_field_formatter_view().

File

modules/file/file.field.inc, line 975
Field module functionality for the File module.

Code

function file_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
  $element = array();
  switch ($display['type']) {
    case 'file_default':
      foreach ($items as $delta => $item) {
        $element[$delta] = array(
          '#theme' => 'file_link',
          '#file' => (object) $item,
        );
      }
      break;
    case 'file_url_plain':
      foreach ($items as $delta => $item) {
        $element[$delta] = array(
          '#markup' => empty($item['uri']) ? '' : file_create_url($item['uri']),
        );
      }
      break;
    case 'file_table':
      if (!empty($items)) {

        // Display all values in a single element..
        $element[0] = array(
          '#theme' => 'file_formatter_table',
          '#items' => $items,
        );
      }
      break;
  }
  return $element;
}