--- contrib/emvideo/emvideo.theme.inc	Fri Jan 16 05:21:36 1970
+++ contrib/emvideo/emvideo.theme.inc	Fri Jan 16 05:21:36 1970
@@ -123,13 +123,13 @@
   $link_url = isset($options['link_url']) ? $options['link_url'] : 'node/'. $node->nid;
 
   // Define the title/alt to display for the link hover.
-  $link_title = isset($options['link_title']) ? $options['link_title'] : (isset($options['title']) ? $options['title'] : (isset($field['widget']['thumbnail_link_title']) ? $field['widget']['thumbnail_link_title'] : variable_get('emvideo_default_thumbnail_link_title', t('See video'))));
+  $link_title = isset($options['link_title']) ? $options['link_title'] : (isset($options['title']) ? $options['title'] : (isset($field['widget']['thumbnail_link_title']) ? $field['widget']['thumbnail_link_title'] : (isset($item['title']) ? $item['title'] : variable_get('emvideo_default_thumbnail_link_title', t('See video')))));
   if (module_exists('token')) {
     // Allow the editor to use [title] tokens.
     $link_title = token_replace($link_title, 'global', $node);
   }
-  $image_title = isset($options['image_title']) ? $options['image_title'] : $link_title;
-  $image_alt = isset($options['image_alt']) ? $options['image_alt'] : $link_title;
+  $image_title = isset($options['image_title']) ? $options['image_title'] : (isset($item['title']) ? $item['title'] : $link_title);
+  $image_alt = isset($options['image_alt']) ? $options['image_alt'] : (isset($item['description']) ? $item['description'] : $link_title);
 
   if (isset($thumbnail_url)) {
     if ($options['absolute']) {
@@ -217,7 +217,7 @@
 }
 
 function theme_emvideo_modal_generic($field, $item, $formatter, $node, $options = array()) {
-  $title = isset($options['title']) ? $options['title'] : (isset($node->title) ? $node->title : (isset($node->node_title) ? $node->node_title : (isset($field['widget']['thumbnail_link_title']) ? $field['widget']['thumbnail_link_title'] : variable_get('emvideo_default_thumbnail_link_title', t('See video')))));
+  $title = isset($options['title']) ? $options['title'] : (isset($item['title']) ? $item['title'] : (isset($node->title) ? $node->title : (isset($node->node_title) ? $node->node_title : (isset($field['widget']['thumbnail_link_title']) ? $field['widget']['thumbnail_link_title'] : variable_get('emvideo_default_thumbnail_link_title', t('See video'))))));
   $thumbnail = isset($options['thumbnail']) ? $options['thumbnail'] : theme('emvideo_video_thumbnail', $field, $item, 'video_thumbnail', $node, TRUE, $options);
   $width = ($formatter == 'video_replace_preview') ? $field['widget']['preview_width'] : $field['widget']['video_width'];
   $height = ($formatter == 'video_replace_preview') ? $field['widget']['preview_height'] : $field['widget']['video_height'];
@@ -258,7 +258,14 @@
   if ($options['wrapper-class']) {
     $class .= ' '. $options['wrapper-class'];
   }
-  $output = '<div class="'. $class .'">'. l($thumbnail, $destination, $attributes) .'</div>';
+  $display_title = '';
+  // Create "title" container
+  if (isset($options['title'])) {
+    $display_title = '<div class="item-title">'. $options['title'] ."</div>";
+  } else if (isset($item['title'])) {
+    $display_title = '<div class="item-title">'. $item['title']. "</div>";
+  }
+  $output = '<div class="'. $class .'">'. l($thumbnail, $destination, $attributes) . $display_title .'</div>';
   return $output;
 }
 
--- contrib/emvideo/emvideo.module	Fri Jan 16 05:21:36 1970
+++ contrib/emvideo/emvideo.module	Fri Jan 16 05:21:36 1970
@@ -535,6 +535,22 @@
         if (module_exists('token')) {
           $form['tn']['thumbnail_link_title']['#suffix'] = theme('token_help', 'global');
         }
+
+        $form['meta_data'] = array(
+          '#type' => 'fieldset',
+          '#title' => t('Additional fields'),
+          '#description' => t('Makes addition fields available for describing your content.'),
+          '#collapsible' => TRUE,
+          '#collapsed' => FALSE,
+        );
+        $form['meta_data']['meta_fields'] = array(
+          '#type' => 'checkboxes',
+          '#title' => t('Additional fields'),
+          '#multiple' => TRUE,
+          '#default_value' => is_array($widget['meta_fields']) ? $widget['meta_fields'] : array(),
+          '#options' => array('title' => t('Title'), 'description' => t('Description')),
+        );
+
       }
       return $form;
 
@@ -563,7 +579,7 @@
 
     case 'save':
       if ($widget['widget_type'] == 'emvideo_textfields') {
-        $columns = array('video_width', 'video_height', 'video_autoplay', 'preview_width', 'preview_height', 'preview_autoplay', 'thumbnail_width', 'thumbnail_height', 'thumbnail_default_path', 'thumbnail_link_title');
+        $columns = array('video_width', 'video_height', 'video_autoplay', 'preview_width', 'preview_height', 'preview_autoplay', 'thumbnail_width', 'thumbnail_height', 'thumbnail_default_path', 'thumbnail_link_title', 'meta_fields');
         $columns = array_merge($columns, emfield_emfield_widget_settings('save', $widget, 'emvideo'));
         return $columns;
       }
@@ -679,6 +695,131 @@
 }
 
 /**
+*  Implements hook_emfield_field_columns_extra().
+*  This is called to add 2 extra columns to the database to store the title and description.
+*/
+
+function emvideo_emfield_field_columns_extra(){
+  $columns = array(
+    'title' => array('type' => 'varchar', 'length' => 255, 'not null' => FALSE, 'sortable' => TRUE),
+    'description' => array('type' => 'varchar', 'length' => 255, 'not null' => FALSE, 'sortable' => TRUE),
+    );
+  return $columns;
+}
+
+/**
+*  Implements hook_emfield_field_extra().
+*  This is called on field operations to allow us to act on emvideos.
+*/
+function emvideo_emfield_field_extra($op, &$node, $field, &$items, $teaser, $page, $module) {
+  switch ($op) {
+    case 'validate':
+      // Title and Description should be optional.
+      /*
+      if (!isset($field['submit'])) {
+        foreach ($items as $delta => $item) {
+          if (isset($item['embed']) && !empty($item['embed'])) {
+            if (empty($item['emvideo']['title'])) {
+              $err_msg[] = 'Video Title';
+            }
+            if (empty($item['emvideo']['description'])) {
+              $err_msg[] = 'Video Description';
+            }
+            if (isset($err_msg)) {
+              $plural = (count($err_msg)==1)?' is':'s are';
+              form_set_error('emvideo', implode(' and ', $err_msg).' field'.$plural.' required.');
+            }
+          }
+        }
+      }
+      */
+      break;
+    case 'insert':
+    case 'update':
+      // Called before content.module defaults.
+      foreach ($items as $delta => $item) {
+        if (isset($item['emvideo']['delete']) && $item['emvideo']['delete']) {
+          $items[$delta]['embed'] = NULL;
+          $items[$delta]['value'] = NULL;
+          $items[$delta]['provider'] = NULL;
+          $items[$delta]['data'] = NULL;
+          $items[$delta]['embed'] = NULL;
+          $items[$delta]['version'] = 0;
+          $items[$delta]['duration'] = 0;
+          $items[$delta]['title'] = NULL;
+          $items[$delta]['description'] = NULL;
+        } else {
+          // Add alt text and alt title
+          if (!empty($items[$delta]['emvideo']['title'])) {
+            $items[$delta]['title'] = $items[$delta]['emvideo']['title'];
+          }
+          if (!empty($items[$delta]['emvideo']['description'])) {
+            $items[$delta]['description'] = $items[$delta]['emvideo']['description'];
+          }
+        }
+      }
+      // We're saving in the data property so delete emvideo
+      if (isset($items[$delta]['emvideo'])) {
+        unset($items[$delta]['emvideo']);
+      }
+      // FIX FOR STATUS FIELD
+      if (!isset($items[$delta]['status'])) {
+        $items[$delta]['status'] = EMFIELD_STATUS_AVAILABLE;
+      }
+      // FIX FOR DATA NOT EMPTY
+      if (empty($items[$delta]['data'])) {
+         unset($items[$delta]['data']);
+      }
+      // Compact deltas.
+      $items = array_values($items);
+      //dpm($items);
+      break;
+  }
+}
+
+/**
+*  Implements hook_emfield_widget_extra().
+*/
+function emvideo_emfield_widget_extra($form, $form_state, $field, $items, $delta = 0, $module) {
+  $element = array();
+  if ($module == 'emvideo') {
+    // Add a title field, but only if the field is allowed.
+    // If the title is already being used allow it for editing even if it is disabled.
+    if ($field['widget']['meta_fields']['title'] || !empty($items[$delta]['title'])) {
+      $element['title'] = array(
+        '#type' => 'textfield',
+        '#title' => t('Video Title'),
+        '#default_value' => isset($items[$delta]['title']) ? $items[$delta]['title'] : '',
+        '#size' => 60,
+        '#maxlength' => 35,
+        '#description' => t('The title for the video.'),
+      );
+    }
+    // Add a description field, but only if the field is allowed.
+    // If the description is already being used allow it for editing even if it is disabled.
+    if ($field['widget']['meta_fields']['description'] || !empty($items[$delta]['description'])) {
+      $element['description'] = array(
+        '#type' => 'textfield',
+        '#title' => t('Video Description'),
+        '#default_value' => isset($items[$delta]['description']) ? $items[$delta]['description'] : '',
+        '#size' => 60,
+        '#maxlength' => 100,
+        '#description' => t('The description for the video.  Provide text for visitors who can not see the images in page.'),
+      );
+    }
+    if (!empty($items[$delta]['embed'])) {
+      $element['delete'] = array(
+        '#type' => 'checkbox',
+        '#title' => t('Delete the Video'),
+        '#description' => t("Checking this field will delete the video."),
+        '#default_value' => 0,
+        );
+    }
+  }
+  return $element;
+}
+
+/**
  * Implementation of hook_views_api().
  */
 function emvideo_views_api() {
@@ -687,4 +828,5 @@
     'path' => drupal_get_path('module', 'emvideo') . '/includes/views',
   );
 }
+
 
