? LICENSE.txt
? uc_option_image_550344_1.patch
Index: uc_option_image.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/uc_option_image/uc_option_image.info,v
retrieving revision 1.4
diff -u -p -r1.4 uc_option_image.info
--- uc_option_image.info	14 Apr 2009 18:59:30 -0000	1.4
+++ uc_option_image.info	16 Aug 2009 20:51:08 -0000
@@ -4,3 +4,10 @@ dependencies[] = uc_attribute
 dependencies[] = imagecache
 package = "Ubercart - core (optional)"
 core = 6.x
+
+; Information added by drupal.org packaging script on 2009-04-21
+version = "6.x-1.4"
+core = "6.x"
+project = "uc_option_image"
+datestamp = "1240286767"
+
Index: uc_option_image.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/uc_option_image/uc_option_image.install,v
retrieving revision 1.4
diff -u -p -r1.4 uc_option_image.install
--- uc_option_image.install	21 Apr 2009 03:59:52 -0000	1.4
+++ uc_option_image.install	16 Aug 2009 20:51:08 -0000
@@ -8,7 +8,7 @@ function uc_option_image_install($no_ima
   if ($info) {
     $file = (object) array(
       'uid' => 1,
-      'filename' => 'option_image_0_0_0';
+      'filename' => 'option_image_0_0_0',
       'filepath' => $no_image,
       'filemime' => $info['file_mime'],
       'filesize' => $info['file_size'],
Index: uc_option_image.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/uc_option_image/uc_option_image.js,v
retrieving revision 1.5
diff -u -p -r1.5 uc_option_image.js
--- uc_option_image.js	14 Apr 2009 18:59:30 -0000	1.5
+++ uc_option_image.js	16 Aug 2009 20:51:09 -0000
@@ -11,6 +11,7 @@ UCOI.init = function() {
   this.noimage = Drupal.settings.UCOI.noimage;
   this.attributes = Drupal.settings.UCOI.attributes;
   this.defaultSize = Drupal.settings.UCOI.default_size;
+  this.use_lightbox = Drupal.settings.UCOI.use_lightbox;
   
   // Selects                                      
   $('.add-to-cart select.form-select').change(function(){
@@ -25,6 +26,15 @@ UCOI.init = function() {
       UCOI.switchImage(aid, this, size);  
     }
   });
+
+  //onload functions
+  //$('.add-to-cart .form-radios input').onload(function(){
+  //  if (aid = UCOI.getAID(this)){
+  //    UCOI.switchImage(aid, this, size);
+  //  }
+  //});
+
+
 };
 
 /**
@@ -34,19 +44,41 @@ UCOI.switchImage = function(aid, input, 
   var pid = $(input).parents('.node').attr('id');
   var nid = pid.replace('node-', '');             
   var oid = $(input).val(); 
-  var image = $(input).parents('.content').children('img.uc-option-image');       
-          
+  var image;
+  var lightbox = $(input).parents('.content').children('div.uc-option-image-block').children('a.lightbox-processed');  
+  
+  if (this.use_lightbox)
+     image = $(input).parents('.content').children('div.uc-option-image-block').children('a.lightbox-processed').children('img.uc-option-image'); 
+  else
+     image = $(input).parents('.content').children('div.uc-option-image-block').children('img.uc-option-image');
+
   // Make sure we have permission to switch this attribute
-  if (this.attributes[aid] === 0){
+  if (this.attributes[aid] == 0){
     return;
   }
           
   try {          
     var images = this.images[nid][aid];
-    
-    if (images[oid].derivative){ 
-      this.switchImageEffect(image, images[oid].derivative);
-    } 
+
+    if (images[oid].derivative=="" && image){
+	parentImage = image[0].parentNode;
+	parentImage.removeChild(image[0]);    
+    }else if (image[0] && images[oid].derivative){ 
+      this.switchImageEffect(image, lightbox, images[oid]);
+    } else if (image[0] == null){
+       if (this.use_lightbox)
+         parentImage = $(input).parents('.content').children('div.uc-option-image-block').children('a.lightbox-processed');
+       else
+         parentImage = $(input).parents('.content').children('div.uc-option-image-block');
+
+        //parentImage[0].innerHTML = "<img src=\""+images[oid].derivative+"\" class=\"uc-option-image\">";
+        objectToAppend = document.createElement("img");
+        objectToAppend.setAttribute("src",images[oid].derivative);
+        objectToAppend.setAttribute("class","uc-option-image");
+        parentImage[0].appendChild(objectToAppend);
+       if (this.use_lightbox)
+          $(lightbox).attr('href',images[oid].lightbox);
+    }
   }
   catch (e){   
     this.switchImageEffect(image, this.noimage); 
@@ -56,16 +88,20 @@ UCOI.switchImage = function(aid, input, 
 /**
  * Switch the imagepath based on the selected effect.
  */
-UCOI.switchImageEffect = function(image, imagepath) {
-  switch(this.effect){
+UCOI.switchImageEffect = function(image, lightbox, imageproperty) {
+  
+   if (this.use_lightbox)
+      $(lightbox).attr('href',imageproperty.lightbox);
+
+   switch(this.effect){
     case 'fade':
-      $(image).fadeOut(200, function(){
-        $(this).attr('src', imagepath).fadeIn(200);
+      $(image).fadeOut(200, function(){		      
+        $(this).attr('src', imageproperty.derivative).fadeIn(200);
       });
       break;
       
     default:
-      $(image).attr('src', imagepath); 
+      $(image).attr('src', imageproperty.derivative); 
   }
 };
 
@@ -81,4 +117,4 @@ if (Drupal.jsEnabled) {
   $(function(){
     UCOI.init();
   });
-}
\ No newline at end of file
+}
Index: uc_option_image.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/uc_option_image/uc_option_image.module,v
retrieving revision 1.22
diff -u -p -r1.22 uc_option_image.module
--- uc_option_image.module	16 Apr 2009 19:26:50 -0000	1.22
+++ uc_option_image.module	16 Aug 2009 20:51:09 -0000
@@ -36,13 +36,15 @@ function uc_option_image_nodeapi(&$node,
       $node->option_images = array();
       $node->option_images_cached = array();
       $node->attributes = uc_product_get_attributes($node->nid);
+      $attribute_same_image = variable_get('uc_option_image_same_image','');
        
       if (count($node->attributes)) {
         $page_size = variable_get('uc_option_image_page_size', 'preview');     
         foreach($node->attributes AS $attribute) {
           if (count($attribute->options)) {
             foreach($attribute->options AS $option) {
-              $file = uc_option_image_load($node->nid, $attribute->aid, $option->oid);
+              $same = $attribute_same_image[$attribute->aid];
+              $file = uc_option_image_load($node->nid, $attribute->aid, $option->oid,$same);
               if ($file && $file->filepath) {
                 $node->option_images[] = $file;
                 // Load imagecached option images
@@ -50,7 +52,7 @@ function uc_option_image_nodeapi(&$node,
                   $node->option_images_cached[$option->oid] = imagecache_create_url($page_size, $file->filepath);
                 }
                 else {
-                  $node->option_images_cached[$option->oid] = $file->filepath;
+                  $node->option_images_cached[$option->oid] = '/'.$file->filepath;
                 }
               }
             }
@@ -66,10 +68,11 @@ function uc_option_image_nodeapi(&$node,
         if (user_access('view option images')){
           if (count($node->attributes)){ 
             $attributes = $node->attributes;          
-            $first_attribute = array_shift($node->attributes);  
+            $attribute_same_image = variable_get('uc_option_image_same_image','');
+            $first_attribute = array_shift($node->attributes);               
             array_unshift($node->attributes, $first_attribute);
             $page_size = variable_get('uc_option_image_page_size', 'preview');  
-            $teaser_size = variable_get('uc_option_image_teaser_size', 'thumbnail'); 
+            $teaser_size = variable_get('uc_option_image_teaser_size', 'thumbnail');
             $size = $a4 ? $page_size : $teaser_size;
                    
             // Pass attributes to uc_option_image to populate JS settings
@@ -80,16 +83,18 @@ function uc_option_image_nodeapi(&$node,
             // Determine if we have a default option using
             // the first attribute's default option
             if ($first_attribute->default_option){
-              $default_option = $first_attribute->default_option;
+
+              $default_option = $first_attribute->default_option;              
             }
                                        
             // Load the default image file
-            $file = uc_option_image_load($node->nid, $first_attribute->aid, $default_option);
-                      
+            $same = $attribute_same_image[$first_attribute->aid];
+            
+            $file = uc_option_image_load($node->nid, $first_attribute->aid, $default_option,$same);                     
             // Display the image based on teaser/page view
             // Ensure that original file exists
             if ($file->filepath && file_exists($file->filepath)){
-              $image = theme('uc_option_image', $file, $size);  
+              $image = theme('uc_option_image', $first_attribute->aid, $file, $size);  
             }
             else {   
               $image = theme('uc_option_image_no_image', $node, $size);
@@ -97,14 +102,14 @@ function uc_option_image_nodeapi(&$node,
             
             // Preload images
             if ($a4){
-              $preloaded_images = theme('uc_option_image_preloaded', $node, $size); 
+              $preloaded_images = theme('uc_option_image_preloaded', $first_attribute->aid, $node, $size); 
             }
             
             $node->content['option_image'] = array(
                 '#value' => $image . $preloaded_images,
                 '#access' => user_access('view option images'),
                 '#weight' => (int) variable_get('uc_option_image_node_weight', '10'),
-              );      
+              );                             
           }
         }
       }
@@ -115,43 +120,58 @@ function uc_option_image_nodeapi(&$node,
 /**
  * Implementation of hook_form_alter();
  */
-function uc_option_image_form_alter(&$form, &$form_state, $form_id){ 
+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'){
+      if (!is_numeric(arg(1)) && arg(0) != 'node')
+      {
         return;
       }           
       // Add option image previews and browse fields
-      if ($aids = element_children($form['attributes'])){  
+      if ($aids = element_children($form['attributes']))
+      {  
         $node = menu_get_object();
         $nid = $node->nid;
         $attributes = variable_get('uc_option_image_attributes', '');
-                                       
-        foreach($aids AS $aid) { 
+        $attribute_same_image = variable_get('uc_option_image_same_image','');                               
+        foreach($aids AS $aid) 
+        {         
           // Make sure the attribute is switchable
-          if (isset($attributes[$aid]) && !$attributes[$aid]){
+          if (isset($attributes[$aid]) && !$attributes[$aid])
+          {
             continue;
           }
           
           // Display fields
-          if ($oids = element_children($form['attributes'][$aid]['options'])){ 
-            foreach($oids AS $oid) { 
-              $file = uc_option_image_load($nid, $aid, $oid);
+          if ($oids = element_children($form['attributes'][$aid]['options']))
+          {
+            $same = $attribute_same_image[$aid]; 
+            foreach($oids AS $oid) 
+            { 
+              $file = uc_option_image_load($nid, $aid, $oid,$same);
               
-              if (!empty($file)) {
+              if (!empty($file)) 
+              {
                 $form['attributes'][$aid]['options'][$oid]['option_image_preview'] = array(
                   '#type' => 'markup',                       
-                  '#value' => theme('uc_option_image', $file, variable_get('uc_option_image_preview_size', '_original')),       
+                  '#value' => theme('uc_option_image', $aid, $file, variable_get('uc_option_image_preview_size', '_original')),       
                 );
                 $form['attributes'][$aid]['options'][$oid][uc_option_image_id($nid, $aid, $oid)] = array(
                   '#type' => 'file',
                   '#title' => t('Image'),
-                  '#name' => 'files[' . uc_option_image_id($nid, $aid, $oid) . ']',
+                  //'#name' => 'files[' . uc_option_image_id($nid, $aid, $oid) . ']',
+                  '#name' => 'files[' . $file->filename . ']',
                   '#size' => 8,
                   '#default_value' => $file->filename,       
                 );
+                if ($file->filename != 'option_image_0_0_0') {
+                   $form['attributes'][$aid]['options'][$oid]['remove'] = array(
+                     '#type' => 'checkbox',
+                   );
+                }
               }
             }
           } 
@@ -171,7 +191,8 @@ function uc_option_image_form_alter(&$fo
       $presets = imagecache_presets();
       $size_options = uc_option_image_get_size_options();
       $attribute_options = uc_option_image_get_attribute_options(); 
-      
+      $attribute_same_image = $attribute_options;
+
       // Ensure we have imagecache presets otherwise
       // display a message so they can create presets first.
       if (empty($presets)){
@@ -192,14 +213,61 @@ function uc_option_image_form_alter(&$fo
           '#description' => t('Use JavaScript to switch attribute option images when selected from a select field if it is available.'),
           '#default_value' => variable_get('uc_option_image_js', TRUE),
         );
+      $form['uc_option_image']['uc_option_image_show_noimage'] = array(
+          '#type' => 'checkbox',
+          '#title' => t('Show No Image Icon'),
+          '#description' => t('Show no image icon when there is no image associated with an attribute.'),
+          '#default_value' => variable_get('uc_option_image_show_noimage', FALSE),
+        );
+      if (module_exists('lightbox2'))
+         $form['uc_option_image']['uc_option_image_use_lightbox'] = array(
+            '#type' => 'checkbox',
+            '#title' => t('Use Lightbox'),
+            '#description' => t('Use lightbox to show attribute images when image in front page is clicked.'),
+            '#default_value' => variable_get('uc_option_image_use_lightbox', TRUE),
+          );
+
       if (!empty($attribute_options)){
-        $form['uc_option_image']['uc_option_image_attributes'] = array(
+         // Description
+         /*$form['uc_option_image']['uc_option_image_configure_attributes'] = array(
+               '#type' => 'fieldset',
+               '#title' => t('Configure Attributes'),
+               '#collapsible' => TRUE,
+               '#collapsed' => FALSE,
+               '#tree' => TRUE 
+            );
+
+           $form['uc_option_image']['uc_option_image_configure_attributes']['uc_option_image_enable_attributes'] = array(
+               '#type' => 'fieldset',
+               '#title' => t('Enable option image for the following attributes'),
+               '#collapsible' => TRUE,
+               '#collapsed' => FALSE
+            );
+          */
+          //$form['uc_option_image']['uc_option_image_configure_attributes']['uc_option_image_enable_attributes']['uc_option_image_attributes'] = array(
+          $form['uc_option_image']['uc_option_image_attributes'] = array(
             '#type' => 'checkboxes',
-            '#title' => t('Switch Attributes'),
+            '#title' => t('Enable option image for the following attributes'),
             '#description' => t('Only checked attributes will attempt to be switched when changed. For example you would want to check "Shoe Style" but not "Shoe Size", as "Shoe Size" most likely does not have associated images.'),
             '#options' => $attribute_options,
-            '#default_value' => variable_get('uc_option_image_attributes', ''),
+            '#default_value' => variable_get('uc_option_image_attributes',array()),
+          );
+
+          /*$form['uc_option_image']['uc_option_image_configure_attributes']['enable_option_image_allproducts'] = array(
+               '#type' => 'fieldset',
+               '#title' => t('Set option images to be the same for all products'),
+               '#collapsible' => TRUE,
+               '#collapsed' => FALSE
+            );
+          */
+          //$form['uc_option_image']['uc_option_image_configure_attributes']['enable_option_image_allproducts']['uc_option_image_same_image'] = array(
+          $form['uc_option_image']['uc_option_image_same_image'] = array(
+            '#type' => 'checkboxes',
+            '#title' => t('Set option images toi be the same for all prducts'),
+            '#options' => $attribute_same_image,
+            '#default_value' => variable_get('uc_option_image_same_image', array()),
           );
+
       }
       $form['uc_option_image']['uc_option_image_effect'] = array(
           '#type' => 'select',
@@ -232,6 +300,16 @@ function uc_option_image_form_alter(&$fo
           '#options' => $size_options,
           '#default_value' => variable_get('uc_option_image_page_size', '_original'),
         );
+
+      if (module_exists('lightbox2'))
+         $form['uc_option_image']['uc_option_image_lightbox_size'] = array(
+          '#type' => 'select',
+          '#title' => t('Lightbox Image Size'),
+          '#description' => t('Image size which will display in lightbox when image in page is clicked.'),
+          '#options' => $size_options,
+          '#default_value' => variable_get('uc_option_image_lightbox_size', '_original'),
+           );
+     
       $form['uc_option_image']['uc_option_image_node_weight'] = array(
           '#type' => 'weight',
           '#title' => t('Option Image Weight'),
@@ -283,6 +361,11 @@ function uc_option_image_form_alter(&$fo
       $form['buttons']['#weight'] = 5;        
       break;
   }
+  //if ($form_id == 'uc_product_add_to_cart_form_13')
+  //{
+     //$form['form_array'] = array('#value'=> '<pre>'.print_r($form,1).'</pre>');
+     //dpm($form);     
+  //}
 }
 
 /* -----------------------------------------------------------------
@@ -353,28 +436,50 @@ function uc_option_image($node, $attribu
     $data = array();
     $data['size'] = $size;
     $data['effect'] = variable_get('uc_option_image_effect', 'fade');
-    $data['noimage'] = theme('uc_option_image_no_image_path', $node, $size);
+    if(variable_get('uc_option_image_show_noimage',FALSE))
+      $data['noimage'] = theme('uc_option_image_no_image_path', $node, $size);
     $data['attributes'] = variable_get('uc_option_image_attributes', '');
+    $data['use_lightbox'] = variable_get('uc_option_image_use_lightbox',FALSE);
     $prep = TRUE;
   }                             
-  
+
+  $lightbox_preset = variable_get('uc_option_image_lightbox_size', 'preview');
+  $shownoimage = variable_get('uc_option_image_show_noimage',FALSE);
   // Populate Drupal.settings.UCOI.images
   // this prevents the module from needing additional
   // HTTP requests in order to find the image needed
   // for each option.                               
-  if (count($attributes)){               
-    foreach($attributes AS $aid => $attribute){  
-      if (count($attribute->options)){     
-        foreach($attribute->options AS $oid => $option){
-          $file = uc_option_image_load($node->nid, $aid, $oid);
-                            
-          if ($file->filepath){              
+  if (count($attributes))
+  {             
+    $attribute_same_image = variable_get('uc_option_image_same_image',array()); 
+    foreach($attributes AS $aid => $attribute)
+    {  
+      if (count($attribute->options))
+      {             
+        $same = $attribute_same_image[$aid];
+        foreach($attribute->options AS $oid => $option)
+        {
+          $file = uc_option_image_load($node->nid, $aid, $oid,$same);
+           
+          $lightbox_path='';                 
+          if ($file->filepath)
+          { 
+            $derivative= $node->option_images_cached[$oid];
+
+            if (!$shownoimage && $file->filename=='option_image_0_0_0')
+                  $derivative = '';   
+
+            if ($lightbox_preset == '_original')
+                $lightbox_path = '/'. $file->filepath;
+            else
+                $lightbox_path = imagecache_create_url($lightbox_preset, $file->filepath );           
             $data['images'][$node->nid][$aid][$oid] = array(
                 'nid' => $node->nid,
                 'aid' => $aid,
                 'oid' => $oid,
                 'filepath' => $file->filepath,
-                'derivative' => $node->option_images_cached[$oid],
+                'derivative' => $derivative,
+                'lightbox' => $lightbox_path
               );     
           }
         }
@@ -391,21 +496,40 @@ function uc_option_image($node, $attribu
  * 
  * @todo: static cache
  */
-function uc_option_image_load($nid, $aid, $oid) {
+function uc_option_image_load($nid, $aid, $oid, $same)
+{
   static $files;
-  $filename = uc_option_image_id($nid, $aid, $oid);
-  if (empty($files[$filename])){
-    $files[$filename] = db_fetch_object(db_query("SELECT * FROM {files} WHERE filename = '%s'", $filename));
-    if (empty($files[$filename])) {
+  // try most specific image first
+  $filename = uc_option_image_id($nid, $aid, $oid, FALSE);
+  
+  $filenamesame = uc_option_image_id($nid, $aid, $oid, $same);
+
+  if (empty($files[$filename]) && empty($files[$filenamesame]))
+  {
+    //try most specific filename first
+    $files[$filename] = db_fetch_object(db_query("SELECT * FROM {files} WHERE filename like '%s'", $filename));
+    //if most specific image not found then try to find least specific
+    //try to find an image from an available node
+
+    if (empty($files[$filename]) && $same)
+    {
+        $files[$filenamesame] = db_fetch_object(db_query("SELECT * FROM {files} WHERE filename like '%s' order by fid limit 1", $filenamesame));
+    }
+        
+    if (empty($files[$filename]) && empty($files[$filenamesame])) 
+    {      
       if ($nid) {
-        return uc_option_image_load(0, $aid, $oid);
+        return uc_option_image_load(0, $aid, $oid, $same);
       }
       elseif ($aid && $oid) {
-        return uc_option_image_load(0, 0, 0);
+        return uc_option_image_load(0, 0, 0, $same);
       }
     }
   }
-  return $files[$filename];
+  if (!empty($files[$filename]))
+     return $files[$filename];
+  else
+     return $files[$filenamesame];
 }
 
 /**
@@ -509,8 +633,13 @@ function uc_option_image_get_attribute_o
 /**
  * Returns a unique ID corrosponding to the node id, attribute id, and option.
  */
-function uc_option_image_id($nid, $aid, $oid) {
-  return 'option_image_' . $nid . '_' . $aid . '_' . $oid;
+function uc_option_image_id($nid, $aid, $oid, $same=FALSE)
+{
+  $result =  'option_image_' . $nid . '_' . $aid . '_' . $oid;  
+  if ($same)
+    $result =  'option_image_%_' . $aid . '_' . $oid;
+     
+  return $result;
 }
 
 /* -----------------------------------------------------------------
@@ -525,9 +654,18 @@ function uc_option_image_id($nid, $aid, 
 function uc_option_image_uc_object_options_form($form, &$form_state) {
   if ($aids = element_children($form_state['values']['attributes'])){ 
     foreach($aids AS $aid){ 
-      if ($oids = element_children($form_state['values']['attributes'][$aid]['options'])){ 
-        foreach($oids AS $oid){
-          uc_option_image_save($form_state['values']['id'], $aid, $oid);
+      if ($oids = element_children($form_state['values']['attributes'][$aid]['options']))
+      { 
+        foreach($oids AS $oid)
+        {
+          //uc_option_image_save($form_state['values']['id'], $aid, $oid);
+          if ($form_state['values']['attributes'][$aid]['options'][$oid]['remove']) {
+            uc_option_image_delete($form_state['values']['id'], $aid, $oid);
+          }
+          else {
+            uc_option_image_save($form_state['values']['id'], $aid, $oid);
+          }
+
         }                                                             
       } 
     } 
@@ -586,17 +724,45 @@ function uc_option_image_theme() {
  * @return string
  *   Markup.
  */
-function theme_uc_option_image($file, $size = '_original') {
+function theme_uc_option_image($aid, $file, $size = '_original') 
+{
+  $shownoimage = TRUE;
+  if(!variable_get('uc_option_image_show_noimage',FALSE) && $file->filename=='option_image_0_0_0')
+  {
+     $file->filepath = NULL;
+     $shownoimage = FALSE;
+  }
   $info = pathinfo($file->filepath);               
   $attributes = array('class' => 'uc-option-image');
        
   // Display imagecache preset or the original image      
-  if ($size != '_original'){                    
-    return theme('imagecache', $size, $file->filepath, NULL, NULL, $attributes);                       
-  }      
-  else {                             
-    return theme('image', $file->filepath, NULL, NULL, $attributes, FALSE);  
-  }
+  $imagecache_image = '';
+  if ($shownoimage)
+  {
+    if ($size != '_original'){                    
+      $imagecache_image = theme('imagecache', $size, $file->filepath, NULL, NULL, $attributes);                       
+    } else {                             
+      $imagecache_image =  theme('image', $file->filepath, NULL, NULL, $attributes, FALSE);  
+    }
+  } 
+
+  //create lightbox link 
+  $lightbox_preset = variable_get('uc_option_image_lightbox_size', 'preview');
+  if ($lightbox_preset == '_original')
+      $lightbox_path = '/'.$file->filepath;
+  else
+      $lightbox_path = imagecache_create_url($lightbox_preset, $file->filepath );
+
+  //determine if lightbox will be used
+  if(variable_get('uc_option_image_use_lightbox',FALSE))
+     //$option_image = '<a rel="lightbox[attribute'.$aid.']" alt=" " title="" href="'.$lightbox_path.'">'. $imagecache_image .'</a>';
+     $option_image = '<a rel="lightbox" alt=" " title="" href="'.$lightbox_path.'">'. $imagecache_image .'</a>';
+  else
+     $option_image = $imagecache_image;
+
+  $option_image = '<div class="uc-option-image-block">'.$option_image.'</div>';
+
+  return $option_image;
 }
 
 /**
@@ -610,11 +776,11 @@ function theme_uc_option_image($file, $s
  * @return string
  *   Markup.
  */
-function theme_uc_option_image_preloaded($node, $size = '_original') {
+function theme_uc_option_image_preloaded($aid, $node, $size = '_original') {
   $output = '<div id="uc-option-image-preloaded-' . $node->nid . '" class="uc-option-image-preloaded" style="display: none;">';
   
   foreach((array) $node->option_images AS $i => $option_image){   
-    $output .= theme('uc_option_image', $option_image, $size);
+    $output .= theme('uc_option_image', $aid, $option_image, $size);
   }
   
   $output .= theme('uc_option_image_no_image', $node, $size);
@@ -628,6 +794,11 @@ function theme_uc_option_image_preloaded
  * Theme the no image placeholder. 
  */
 function theme_uc_option_image_no_image($node, $size = '_original') {
+
+  if(!variable_get('uc_option_image_show_noimage',FALSE))
+   return;
+  
+
   $attributes = array('class' => 'uc-option-image');
   $filename = path_to_theme() . '/images/noimage.png';
   
@@ -643,6 +814,7 @@ function theme_uc_option_image_no_image(
  * Theme the no image placeholder. Must be a valid imagepath.
  */
 function theme_uc_option_image_no_image_path($node, $size = '_original') {
+  
   $filename = path_to_theme() . '/images/noimage.png';
   
   if ($size != '_original'){           
@@ -665,7 +837,8 @@ function theme_uc_option_image_no_image_
  * Add our image fields to the table.
  */
 function phptemplate_uc_object_options_form($form) {
-  $header = array(t('Attribute'), t('Options'), t('Default'), t('Cost'), t('Price'), t('Weight'), t('Order'), t('Image'), t('Preview'));
+  //$header = array(t('Attribute'), t('Options'), t('Default'), t('Cost'), t('Price'), t('Weight'), t('Order'), t('Image'), t('Preview'));
+  $header = array(t('Attribute'), t('Options'), t('Default'), t('Cost'), t('Price'), t('Weight'), t('Order'), t('Image'), t('Preview'), t('Remove'));
 
   foreach (element_children($form['attributes']) as $key) {
     $row = array();
@@ -683,7 +856,7 @@ function phptemplate_uc_object_options_f
         // MOD: added the image field and preview
         $row[] = drupal_render($form['attributes'][$key]['options'][$oid][uc_option_image_id(arg(1), $key, $oid)]); 
         $row[] = drupal_render($form['attributes'][$key]['options'][$oid]['option_image_preview']);
-        
+        $row[] = drupal_render($form['attributes'][$key]['options'][$oid]['remove']);      
         if (!$first) {
           // MOD: changed from -7 to -9 to accomidate the new columns 
           $row = array_pad($row, -9, '');
