1 file.module | file_file_formatter_info() |
Implements hook_file_formatter_info().
File
- core/
modules/ file/ file.module, line 594 - Defines a "managed_file" Form API field and a "file" field for Field module.
Code
function file_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_file_formatter_file_field_view',
);
if (!empty($formatter['settings'])) {
$formatters[$key] += array(
'default settings' => $formatter['settings'],
'settings callback' => 'file_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' => '',
),
'view callback' => 'file_file_formatter_file_image_view',
'settings callback' => 'file_file_formatter_file_image_settings',
'hidden' => TRUE,
'mime types' => array('image/*'),
);
}
return $formatters;
}