--- C:/Documents and Settings/Kent Parker/My Documents/Kent/Git 2/uc_option_image.module	Fri Jun 03 17:14:12 2011
+++ C:/Documents and Settings/Kent Parker/My Documents/Kent/Git 2/repository/uc_option_image.new	Fri Jun 03 17:33:24 2011
@@ -121,10 +121,11 @@
  * Implementation of hook_form_alter();
  */
 function uc_option_image_form_alter(&$form, &$form_state, $form_id){   
-  //print $form_id;
+  
   switch($form_id){
     // Attribute options form
     case 'uc_object_options_form': 
+	  
       // Make sure we are a node's options page
       if (!is_numeric(arg(1)) && arg(0) != 'node')
       {
@@ -182,6 +183,40 @@
       }
       break;
     
+	case 'uc_attribute_option_form':
+	  // We use 0 instead of the nid to define the default image for an option
+	  $attribute_same_image = variable_get('uc_option_image_same_image',''); 
+      $aid = arg(3);	  
+	  $oid = arg(5);
+      $same = $attribute_same_image[$aid]; 	  
+      $file = uc_option_image_load(0, arg(3), $oid, $same);
+              
+      if (!empty($file)) 
+      {
+        $form['option_image_preview'] = array(
+          '#type' => 'markup',                       
+                  '#value' => theme('uc_option_image', $aid, $file, variable_get('uc_option_image_preview_size', '_original')),       
+        );
+        $form[uc_option_image_id(0, $aid, $oid)] = array(
+          '#type' => 'file',
+          '#title' => t('Image'),
+          '#name' => 'files[' . uc_option_image_id(0, $aid, $oid) . ']',
+          '#size' => 8,
+          '#default_value' => $file->filename,       
+        );
+        if ($file->filename != 'option_image_0_0_0') {
+           $form['remove'] = array(
+             '#type' => 'checkbox',
+					 '#title' => t('Remove')
+           );
+        }
+      }
+         
+        $form['#submit'][] = 'uc_option_image_uc_attribute_option_form';
+        $form['#attributes'] = array('enctype' => 'multipart/form-data');
+      
+	  break;
+    
     // Attribute settings form  
     case 'uc_attribute_admin_settings':
       if (!user_access('administer option images')){
@@ -672,7 +707,14 @@
     } 
   }    
 }
-
+function uc_option_image_uc_attribute_option_form($form, &$form_state) {
+  if ($form_state['values']['remove']) {
+    uc_option_image_delete(0, $form_state['values']['aid'], $form_state['values']['oid']);
+  }
+  else {
+    uc_option_image_save(0, $form_state['values']['aid'], $form_state['values']['oid']);
+  }
+}
 /* -----------------------------------------------------------------
 
   Themes 
