1 file.field.inc | file_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) |
Implements hook_field_formatter_settings_form().
File
- core/
modules/ file/ file.field.inc, line 420 - Field module functionality for the File module.
Code
function file_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) {
$display = $instance['display'][$view_mode];
$settings = $display['settings'];
$element = array();
if ($display['type'] == 'file_rendered') {
$element['file_view_mode'] = array(
'#title' => t('View mode'),
'#type' => 'select',
'#options' => file_view_mode_labels(),
'#default_value' => $settings['file_view_mode'],
// Never empty, so no #empty_option
);
}
elseif ($display['type'] == 'file_download_link') {
$element['text'] = array(
'#type' => 'textfield',
'#title' => t('Link text'),
'#description' => t('This field supports tokens.'),
'#default_value' => $settings['text'],
'#required' => TRUE,
);
}
elseif ($display['type'] == 'file_audio') {
$element['controls'] = array(
'#title' => t('Show audio controls'),
'#type' => 'checkbox',
'#default_value' => $settings['controls'],
);
$element['autoplay'] = array(
'#title' => t('Autoplay'),
'#type' => 'checkbox',
'#default_value' => $settings['autoplay'],
);
$element['loop'] = array(
'#title' => t('Loop'),
'#type' => 'checkbox',
'#default_value' => $settings['loop'],
);
$element['preload'] = array(
'#title' => t('Preload'),
'#type' => 'select',
'#default_value' => $settings['preload'],
'#options' => backdrop_map_assoc(array('none', 'auto', 'metadata')),
'#empty_option' => 'unspecified',
);
$element['multiple_file_behavior'] = array(
'#title' => t('Display of multiple files'),
'#type' => 'radios',
'#options' => array(
'tags' => t('Use multiple @tag tags, each with a single source', array('@tag' => '<audio>')),
'sources' => t('Use multiple sources within a single @tag tag', array('@tag' => '<audio>')),
),
'#default_value' => $settings['multiple_file_behavior'],
// Hide this setting in the manage file display configuration.
'#access' => !empty($field),
);
}
elseif ($display['type'] == 'file_video') {
$element['controls'] = array(
'#title' => t('Show video controls'),
'#type' => 'checkbox',
'#default_value' => $settings['controls'],
);
$element['autoplay'] = array(
'#title' => t('Autoplay'),
'#type' => 'checkbox',
'#default_value' => $settings['autoplay'],
);
$element['loop'] = array(
'#title' => t('Loop'),
'#type' => 'checkbox',
'#default_value' => $settings['loop'],
);
$element['muted'] = array(
'#title' => t('Muted'),
'#type' => 'checkbox',
'#default_value' => $settings['muted'],
);
$element['width'] = array(
'#type' => 'textfield',
'#title' => t('Width'),
'#default_value' => $settings['width'],
'#size' => 5,
'#maxlength' => 5,
'#field_suffix' => t('pixels'),
);
$element['height'] = array(
'#type' => 'textfield',
'#title' => t('Height'),
'#default_value' => $settings['height'],
'#size' => 5,
'#maxlength' => 5,
'#field_suffix' => t('pixels'),
);
$element['preload'] = array(
'#title' => t('Preload'),
'#type' => 'select',
'#default_value' => $settings['preload'],
'#options' => backdrop_map_assoc(array('none', 'auto', 'metadata')),
'#empty_option' => 'unspecified',
);
$element['multiple_file_behavior'] = array(
'#title' => t('Display of multiple files'),
'#type' => 'radios',
'#options' => array(
'tags' => t('Use multiple @tag tags, each with a single source', array('@tag' => '<video>')),
'sources' => t('Use multiple sources within a single @tag tag', array('@tag' => '<video>')),
),
'#default_value' => $settings['multiple_file_behavior'],
// Hide this setting in the manage file display configuration.
'#access' => !empty($field),
);
}
return $element;
}