You are here

function file_entity_file_formatter_info in D7 Media 7

Implements hook_file_formatter_info().

File

file_entity/file_entity.module, line 299
Extends Drupal file entities to be fieldable and viewable.

Code

function file_entity_file_formatter_info() {
  $formatters = array();

  // Allow file field formatters to be reused for displaying the file entity's
  // file pseudo-field.
  if (module_exists('file')) {
    foreach (field_info_formatter_types() as $field_formatter_type => $field_formatter_info) {
      if (in_array('file', $field_formatter_info['field types'])) {
        $formatters['file_field_' . $field_formatter_type] = array(
          'label' => $field_formatter_info['label'],
          'view callback' => 'file_entity_file_formatter_file_field_view',
        );
        if (isset($field_formatter_info['settings'])) {
          $formatters['file_field_' . $field_formatter_type] += array(
            'default settings' => $field_formatter_info['settings'],
            'settings callback' => 'file_entity_file_formatter_file_field_settings',
          );
        }
      }
    }
  }

  // Add a simple file formatter for displaying an image in a chosen style.
  if (module_exists('image')) {
    $formatters['file_image'] = array(
      'label' => t('Image'),
      'default settings' => array(
        'image_style' => '',
      ),
      'view callback' => 'file_entity_file_formatter_file_image_view',
      'settings callback' => 'file_entity_file_formatter_file_image_settings',
    );
  }
  return $formatters;
}