# This patch file was generated by NetBeans IDE
# This patch can be applied using context Tools: Apply Diff Patch action on respective folder.
# It uses platform neutral UTF-8 encoding.
# Above lines and this line are ignored by the patching process.
--- a/video_filter_field_orig.module
+++ b/video_filter_field.module
@@ -12,7 +12,7 @@
       'label' => t('Video Filter'),
       'description' => t('This field stores URLs and settings to be '
                        . 'handled by the Video Filter module.'),
-      'settings' => array(),
+      'settings' => array('width_height' => 'allow'),
       'instance_settings' => array(
         'max_height' => 400,
         'max_width' => 400,
@@ -99,6 +99,7 @@
         //  'message'  => t('Video Filter Field: Invalid video URL'),
         //);
         // If URL isn't empty, we need a height.
+        if ($field['settings']['width_height'] == 'allow') {
         if (empty($item['height']) || !is_numeric($item['height'])) {
           $errors[$field['field_name']][$langcode][$delta][] = array( 
             'error' => 'video_filter_height',
@@ -113,6 +114,7 @@
           );
         }
       } 
+      }
       // URL field is empty. Set everything else to empty.
       else {
         unset($items);    
@@ -151,6 +153,8 @@
   //dsm($instance,' instance');
   
   if ($instance['widget']['type'] == 'video_filter') {
+   
+    if (isset ($field['settings']['width_height']) && $field['settings']['width_height'] == 'allow') {
     $element['url'] = array(
       '#type' => 'textfield',
       '#title' => t('Video URL'),
@@ -180,10 +184,42 @@
       '#weight' => 3,
     ) + $base;
   }
+    else {
+      $element['url'] = array(
+        '#type' => 'textfield',
+        '#title' => t('Video URL'),
+        '#default_value' => isset($items[$delta]['url']) ? 
+                            $items[$delta]['url'] : NULL,
+        '#weight' => 0,
+        ) + $base;      
+    } // End else
+    
+    // Message if the patch has been applyed, but the user hasn't flushed the cache
+    if(!isset($field['settings']['width_height'])){
+      drupal_set_message(t("Please, Flush the cache to apply changes"), 'warning');
+    }
+    
+  } // End  $instance['widget']['type'] == 'video_filter'
+  
   return $element;
 }
 
 /**
+ * Implements hook_field_settings_form().
+ */
+function video_filter_field_field_settings_form($field, $instance, $has_data) {
+  $settings = $field['settings'];
+  $form['width_height'] = array(
+    '#title' => t('Should the user be allowed to enter in their own width and height or will this be managed by the display formatter?'),
+    '#type' => 'select',
+    '#options' => array('allow' => t('Allow user to enter video display dimensions'), 'dont' => t('Do not allow user to enter video display dimensions')),
+    '#default_value' => $settings['width_height'],
+    '#weight' => 0,
+  );
+  return $form;
+}
+
+/**
  * Implements hook_field_formatter_info().
  */
 function video_filter_field_field_formatter_info() { 
@@ -192,10 +228,81 @@
       'label' => t('Video Filter'),
       'field types' => array('text', 'video_filter'),
     ),
+    'video_filter_field_custom' => array(
+      'label' => t('Video Filter Custom'), 
+      'field types' => array('text', 'video_filter'),
+      'settings' => array('custom_height' => '400','custom_width' => '400','custom_autoplay' => '0'),
+    ),
   );
 } 
 
 /**
+ * Implements hook_field_formatter_settings_form()
+ */
+function video_filter_field_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) {
+  
+  $display = $instance['display'][$view_mode];
+  $settings = $display['settings'];
+  $element = array();
+  
+  if ($display['type'] == 'video_filter_field_custom') {  
+  $element['custom_width'] = array(
+    '#title' => t('Width'),
+    '#type' => 'textfield',
+    '#size' => 4,
+    '#default_value' => $settings['custom_width'],
+    '#description' => t('Specify width'),
+    '#tree' => TRUE,
+    '#weight' => 1,
+    '#element_validate' => array('element_validate_integer_positive'), 
+    '#required' => TRUE,
+    );
+  $element['custom_height'] = array(
+    '#title' => t('Height'),
+    '#type' => 'textfield',
+    '#size' => 4,
+    '#default_value' => $settings['custom_height'],
+    '#description' => t('Specify height'),
+    '#tree' => TRUE,
+    '#weight' => 2,
+    '#element_validate' => array('element_validate_integer_positive'), 
+    '#required' => TRUE,
+    );
+  $element['custom_autoplay'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Autoplay'),
+    '#default_value' => $settings['custom_autoplay'],
+    '#description' => t('Autoplay?'),
+    '#tree' => TRUE,
+    '#weight' => 3,
+    );
+  }
+  return $element;
+}
+
+/**
+ * Implements hook_field_formatter_settings_summary().
+ */
+function video_filter_field_field_formatter_settings_summary($field, $instance, $view_mode) {
+  $view = $instance['display'][$view_mode];
+
+  $info = '';
+
+  // $settings = $view['settings'];
+  if(isset($instance['default_value'])){
+    $settings = $instance['default_value'][0];
+
+    $width = '<b>' . $settings['width'] . '</b>';
+    $height = '<b>' . $settings['height'] . '</b>';
+    $autoplay = '<b>' . $settings['autoplay'] . '</b>';
+    if ($view['type'] == 'video_filter_field_custom') {
+      $info =  t('Video display width: !width<br>Video display height: !height<br>Video display autoplay: !autoplay', array('!width' => $width,'!height' => $height,'!autoplay' => $autoplay));
+    }
+  }
+  return $info;
+}
+
+/**
  * Implements hook_field_formatter_view().
  */
 function video_filter_field_field_formatter_view($obj_type, $object, $field, 
@@ -212,20 +319,42 @@
 dsm($items,'items');
 // */
 
-  $elements = array();
+  $element = array();
+  $settings = $display['settings'];
+
+  switch ($display['type']) {
+    case 'video_filter_field_default':
   foreach ($items as $delta => $item) {
     $url = url($item['url']);
     $text = "[video:$url]";
 
-    $elements[$delta] = array(
+        $element[$delta] = array(
       '#theme' => 'video_filter_field_default_formatter',
       '#item' => video_filter_field_process($text, $item),
     );
   }
+      break;
 
-  return $elements;
+    case 'video_filter_field_custom':
+      foreach ($items as $delta => $item) {
+        $width = $settings['custom_width'];
+        $height = $settings['custom_height'];
+        $autoplay = $settings['custom_autoplay'];
+        $url = url($item['url']);
+        $text = "[video:$url width:$width height:$height autoplay:$autoplay]";
+        
+        $element[$delta] = array(
+          '#theme' => 'video_filter_field_default_formatter',
+          '#item' => video_filter_field_process($text, $item),
+        );
 }
+      break;
+   }
 
+  return $element;
+
+ }
+
 /**
  * Implements hook_theme().
  */
