function file_field_formatter_view

Implements hook_field_formatter_view().

File

modules/file/file.field.inc, line 975

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

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.