function file_entity_file_formatter_info in File Entity (fieldable files) 7.2
Same name and namespace in other branches
- 7.3 file_entity.module \file_entity_file_formatter_info()
- 7 file_entity.module \file_entity_file_formatter_info()
Implements hook_file_formatter_info().
File
- ./
file_entity.module, line 1123 - 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.
foreach (field_info_formatter_types() as $key => $formatter) {
if (array_intersect($formatter['field types'], array(
'file',
'image',
))) {
$key = 'file_field_' . $key;
$formatters[$key] = array(
'label' => $formatter['label'],
'description' => !empty($formatter['description']) ? $formatter['description'] : '',
'view callback' => 'file_entity_file_formatter_file_field_view',
);
if (!empty($formatter['settings'])) {
$formatters[$key] += array(
'default settings' => $formatter['settings'],
'settings callback' => 'file_entity_file_formatter_file_field_settings',
);
}
if (!empty($formatter['file formatter'])) {
$formatters[$key] += $formatter['file formatter'];
}
}
}
// 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' => '',
'alt' => '[file:field-file-image-alt-text]',
'title' => '[file:field-file-image-title-text]',
),
'view callback' => 'file_entity_file_formatter_file_image_view',
'settings callback' => 'file_entity_file_formatter_file_image_settings',
'hidden' => TRUE,
'mime types' => array(
'image/*',
),
);
}
return $formatters;
}