--- videojs.module Mon Jun 11 23:04:00 2012 +++ videojs.module Fri Aug 24 12:23:15 2012 @@ -62,6 +62,10 @@ 'label' => t('Video.js : HTML5 Video Player'), 'field types' => array('file', 'media', 'link_field'), 'description' => t('Display a video file as an HTML5-compatible with Flash-fallback video player.'), + 'settings' => array( //Array of the settings we'll create + 'width' => variable_get('videojs_width', 640), + 'height' => variable_get('videojs_height', 264), + ), ), ); } @@ -76,6 +80,7 @@ if (empty($items)) { return array(); } + $settings = $display['settings']; // get the settings if ($field['type'] == 'link_field') { $links = $items; @@ -113,8 +118,55 @@ '#items' => $items, '#player_id' => 'videojs-' . $id . '-' . str_replace('_', '-', $instance['field_name']), '#attached' => videojs_add(FALSE), + '#attributes' => array( + 'width' => isset($settings['width']) ? $settings['width'] : variable_get('videojs_width', 640), + 'height' => isset($settings['height']) ? $settings['height'] : variable_get('videojs_height', 264), + ), ), ); +} + +/** + * Implements hook_field_formatter_settings_form(). + */ +function videojs_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) { + //This gets the view_mode where our settings are stored + $display = $instance['display'][$view_mode]; + //This gets the actual settings + $settings = $display['settings']; + //Initialize the element variable + $element = array(); + //Add your select box + $element['width'] = array( + '#type' => 'textfield', + '#title' => t('Width'), + '#default_value' => $settings['width'], + '#size' => 6, + '#maxlength' => 5, + '#required' => TRUE, + ); + $element['height'] = array( + '#type' => 'textfield', + '#title' => t('Height'), + '#default_value' => $settings['height'], + '#size' => 6, + '#maxlength' => 5, + '#required' => TRUE, + ); + return $element; +} + +/** + * Implements hook_field_formatter_settings_summary(). + */ +function videojs_field_formatter_settings_summary($field, $instance, $view_mode) { + $display = $instance['display'][$view_mode]; + $settings = $display['settings']; + $summary = t('Width @width, height @height', array( + '@width' => $settings['width'], + '@height' => $settings['height'], + )); // we use t() for translation and placeholders to guard against attacks + return $summary; } /**