function videojs_field_formatter_settings_form in Video.js (HTML5 Video Player) 7.3
Same name and namespace in other branches
- 7.2 videojs.module \videojs_field_formatter_settings_form()
Implements hook_field_formatter_settings_form().
File
- ./
videojs.module, line 225 - Provides an HTML5-compatible with Flash-fallback video player.
Code
function videojs_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) {
$display = $instance['display'][$view_mode];
$settings = $display['settings'];
$entity_type = NULL;
$bundle = NULL;
if (isset($instance['entity_type']) && isset($instance['bundle'])) {
$entity_type = $instance['entity_type'];
$bundle = $instance['bundle'];
}
elseif (isset($form['#file_type'])) {
// The file entity module does not supply the entity type and bundle like
// Drupal core does.
// @todo: file a feature request.
$entity_type = 'file';
$bundle = $form['#file_type'];
}
if ($entity_type != NULL && $bundle != NULL) {
$imagefields = videojs_utility::findFieldsByType($field, $entity_type, $bundle, array(
'image',
'imagefield_crop',
'link',
'file',
));
unset($imagefields[$field['field_name']]);
$trackfields = videojs_utility::findFieldsByType($field, $entity_type, $bundle, array(
'link',
'file',
));
unset($trackfields[$field['field_name']]);
}
$form = array(
'#element_validate' => array(
'videojs_field_formatter_settings_form_validate',
),
);
videojs_utility::getDisplaySettingsForm($form, $settings);
if (!empty($imagefields)) {
$form['posterimage_field'] = array(
'#type' => 'select',
'#title' => t('Poster image field'),
'#default_value' => $settings['posterimage_field'],
'#options' => $imagefields,
'#description' => t('If an image is uploaded to the field above it will be used as the poster image.'),
'#empty_value' => '',
);
if (module_exists('image')) {
$image_styles = image_style_options(FALSE);
$form['posterimage_style'] = array(
'#type' => 'select',
'#title' => t('Poster image style'),
'#default_value' => $settings['posterimage_style'],
'#empty_option' => t('None (original image)'),
'#description' => t('The original video thumbnail will be displayed. Otherwise, you can add a custom image style at !settings.', [
'!settings' => l(t('media image styles'), 'admin/config/media/image-styles'),
]),
'#options' => $image_styles,
);
}
if ($field['type'] == 'file') {
$form['posterimage_field']['#description'] .= ' ' . t('Images uploaded to this field will be used as poster image by default.');
}
if ($field['type'] == 'link_field') {
$form['posterimage_field']['#description'] .= ' ' . t('Images referenced by this field will be used as poster image by default.');
}
}
if (!empty($trackfields)) {
$form['tracks_field'] = array(
'#type' => 'select',
'#title' => t('Field containing text tracks'),
'#default_value' => $settings['tracks_field'],
'#options' => $trackfields,
'#description' => t('VTT text tracks can be read from a separate field for this content type.'),
'#empty_value' => '',
);
if ($field['type'] == 'file') {
$form['tracks_field']['#description'] .= ' ' . t('VTT files uploaded to this field will be used by default.');
}
if ($field['type'] == 'link_field') {
$form['tracks_field']['#description'] .= ' ' . t('VTT files referenced by this field will be used by default.');
}
}
return $form;
}