function video_field_settings_form in Video 7.2
Same name and namespace in other branches
- 7 video.field.inc \video_field_settings_form()
Implements hook_field_settings_form().
File
- ./
video.field.inc, line 79 - Implement a video field, based on the file module's file field.
Code
function video_field_settings_form($field, $instance, $has_data) {
$transcoder = new Transcoder();
$hastranscoder = $transcoder
->hasTranscoder();
$default_file_scheme = variable_get('file_default_scheme', 'public');
$defaults = field_info_field_settings($field['type']);
$settings = array_merge($defaults, $field['settings']);
// Copied from file_field_settings_form().
$scheme_options = array();
foreach (file_get_stream_wrappers(STREAM_WRAPPERS_WRITE_VISIBLE) as $scheme => $stream_wrapper) {
$scheme_options[$scheme] = $stream_wrapper['name'];
}
$form['uri_scheme'] = array(
'#type' => 'radios',
'#title' => t('Upload destination of original file'),
'#options' => $scheme_options,
'#default_value' => $settings['uri_scheme'],
'#description' => t('Select where the original video files should be stored. Private file storage has significantly more overhead than public files, but allows restricted access to files within this field.'),
);
$form['uri_scheme_converted'] = array(
'#type' => 'radios',
'#title' => t('Upload destination of converted files'),
'#options' => $scheme_options,
'#default_value' => $settings['uri_scheme_converted'],
'#description' => t('Select where the converted video files should be stored. Private file storage has significantly more overhead than public files, but allows restricted access to files within this field.'),
'#access' => $hastranscoder,
);
$form['uri_scheme_thumbnails'] = array(
'#type' => 'radios',
'#title' => t('Upload destination of thumbnails'),
'#options' => $scheme_options,
'#default_value' => $settings['uri_scheme_thumbnails'],
'#description' => t('Select where the generated thumbnails should be stored. Private file storage has significantly more overhead than public files, but allows restricted access to files within this field.'),
'#access' => $hastranscoder,
);
// Add warnings for S3
if ($hastranscoder && isset($scheme_options['s3'])) {
$value = $transcoder
->getTranscoder()
->getValue();
if ($value == 'TranscoderAbstractionFactoryFfmpeg') {
$form['uri_scheme']['#description'] .= '<br/>';
$form['uri_scheme']['#description'] .= t('You are using the FFmpeg transcoder. Using @scheme to store videos is not advised because FFmpeg is not able to transcode remote files. Every time FFmpeg needs access to the video, it will be copied to a temporary location.', array(
'@scheme' => $scheme_options['s3'],
));
}
$form['uri_scheme_thumbnails']['#description'] .= '<br/>';
$form['uri_scheme_thumbnails']['#description'] .= t('Be aware that using @scheme to store thumbnails increases the overhead of dynamic image manipulation by the Image module.', array(
'@scheme' => $scheme_options['s3'],
));
}
// Add warnings for streaming to iPad when using the private file system
// See http://www.metaltoad.com/blog/iphone-video-streaming-drupals-file-system
if (isset($scheme_options['private']) && !module_exists('xsendfile') && !module_exists('resumable_download')) {
$ioswarning = '<br/>' . t('Streaming to Apple iOS devices (iPad/iPhone/iPod) is not supported when using the private file system unless a module to support Range requests is installed. Modules that are known to work are <a href="@xsendfile-module">X-Sendfile</a> or <a href="@resumable-download-module">Resumable Download</a>.', array(
'@xsendfile-module' => url('http://drupal.org/project/xsendfile'),
'@resumable-download-module' => url('http://drupal.org/project/resumable_download'),
));
$form['uri_scheme']['#description'] .= $ioswarning;
$form['uri_scheme_converted']['#description'] .= $ioswarning;
}
$form['autoconversion'] = array(
'#type' => 'checkbox',
'#title' => t('Enable auto video conversion'),
'#description' => t('Convert videos automatically using FFmpeg or Zencoder. You can define presets at !preset to automatically convert videos to web compatible formats eg. FLV, MP4. Make sure to configure your !settings to make this work properly.', array(
'!settings' => l(t('transcoder settings'), 'admin/config/media/video/transcoders'),
'!preset' => l(t('preset settings'), 'admin/config/media/video/presets'),
)),
'#default_value' => isset($settings['autoconversion']) ? $settings['autoconversion'] : '',
'#access' => $hastranscoder,
);
$form['thumbnail_format'] = array(
'#title' => t('Thumbnail format'),
'#type' => 'radios',
'#options' => array(
'jpg' => 'JPEG',
'png' => 'PNG',
),
'#default_value' => !empty($settings['thumbnail_format']) ? $settings['thumbnail_format'] : 'jpg',
'#access' => $hastranscoder,
);
$thumb_options = array(
'auto' => 'Automatically extract thumbnails from video (with fallback to manual upload)',
'manual_upload' => 'Manually upload a thumbnail',
'no' => 'Don\'t create thumbnail',
);
// When there is no transcoder, the auto option is not available and should not be the default.
if (!$hastranscoder) {
unset($thumb_options['auto']);
if (!isset($settings['autothumbnail']) || $settings['autothumbnail'] == 'auto') {
$settings['autothumbnail'] = 'no';
}
}
$form['autothumbnail'] = array(
'#type' => 'radios',
'#title' => t('Video thumbnails'),
'#options' => $thumb_options,
'#description' => t('If you choose <i>Automatically extract thumbnails from video</i> then please make sure to configure your !settings to make this work properly.', array(
'!settings' => l(t('transcoder settings'), 'admin/config/media/video/transcoders'),
)),
'#default_value' => isset($settings['autothumbnail']) ? $settings['autothumbnail'] : 'auto',
);
$form['default_video_thumbnail'] = array(
'#title' => t('Default video thumbnail'),
'#type' => 'managed_file',
'#element_validate' => array(
'video_field_default_thumbnail_validate',
),
'#description' => t('You can use a default thumbnail for all videos or videos from which a thumbnail can\'t be extracted. Settings to use default video thumbnails will be available on node edit. You can change the permissions for other users too.'),
'#default_value' => !empty($settings['default_video_thumbnail']['fid']) ? $settings['default_video_thumbnail']['fid'] : '',
'#upload_location' => $default_file_scheme . '://videos/thumbnails/default',
);
$form['preview_video_thumb_style'] = array(
'#title' => t('Preview thumbnail style'),
'#type' => 'select',
'#options' => image_style_options(FALSE),
'#empty_option' => '<' . t('no preview') . '>',
'#default_value' => !empty($settings['preview_video_thumb_style']) ? $settings['preview_video_thumb_style'] : '',
'#description' => t('This image style will be used to show extracted video thumbnails on video node edit. Extracted thumbnail preview will also use this style.'),
);
$selectedpresets = array_filter(variable_get('video_preset', array()));
$presets = Preset::getAllPresets();
$presetnames = array();
foreach ($presets as $preset) {
$presetnames[$preset['name']] = $preset['name'];
if (in_array($preset['name'], $selectedpresets)) {
$presetnames[$preset['name']] .= ' (' . t('default') . ')';
}
}
$form['presets'] = array(
'#title' => t('Presets'),
'#type' => 'checkboxes',
'#options' => $presetnames,
'#default_value' => !empty($settings['presets']) ? $settings['presets'] : array(),
'#description' => t('If any presets are selected, these presets will be used for this field instead of the default presets.'),
'#access' => $hastranscoder,
);
return $form;
}