function file_entity_field_formatter_settings_form in File Entity (fieldable files) 7.2
Same name and namespace in other branches
- 7.3 file_entity.field.inc \file_entity_field_formatter_settings_form()
- 7 file_entity.field.inc \file_entity_field_formatter_settings_form()
Implements hook_field_formatter_settings_form().
File
- ./
file_entity.field.inc, line 107 - Field API integration for the file_entity module.
Code
function file_entity_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_entity_view_mode_labels(),
'#default_value' => $settings['file_view_mode'],
);
}
elseif ($display['type'] == 'file_download_link') {
$element['text'] = array(
'#type' => 'textfield',
'#title' => t('Link text'),
'#description' => t('This field support 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['controls_list'] = array(
'#title' => t('Controls list'),
'#type' => 'checkboxes',
'#options' => array(
'download' => t('Download'),
'remote_playback' => t('Remote playback'),
),
'#default_value' => $settings['controls_list'],
'#description' => t("Customize native media controls such as the download and remoteplayback buttons. Valid only if above \"Show audio controls\" setting is enabled.<br>Please note that not all browsers support this feature. Only Chrome 58+ and Opera 45+ supports it."),
);
$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' => drupal_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['controls_list'] = array(
'#title' => t('Controls list'),
'#type' => 'checkboxes',
'#options' => array(
'fullscreen' => t('Fullscreen'),
'download' => t('Download'),
'remote_playback' => t('Remote playback'),
),
'#default_value' => $settings['controls_list'],
'#description' => t("Customize native media controls such as the download, fullscreen and remoteplayback buttons. Valid only if above \"Show video controls\" setting is enabled.<br>Please note that not all browsers support this feature. Only Chrome 58+ and Opera 45+ supports it."),
);
$element['autoplay'] = array(
'#title' => t('Autoplay'),
'#type' => 'checkbox',
'#default_value' => $settings['autoplay'],
);
$element['playsinline'] = array(
'#title' => t('Plays inline'),
'#type' => 'checkbox',
'#default_value' => $settings['playsinline'],
);
$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' => drupal_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;
}