diff -up -r uc_option_image/uc_option_image.info uc_option_image/uc_option_image.info
--- uc_option_image/uc_option_image.info	2011-02-25 01:55:12.000000000 -0600
+++ uc_option_image/uc_option_image.info	2011-04-26 20:00:18.000000000 -0500
@@ -4,11 +4,11 @@ description = Allows users to upload ima
 dependencies[] = uc_attribute
 dependencies[] = imagecache
 package = Ubercart - extra
-core = 6.x
+core = 7.x
 
 ; Information added by drupal.org packaging script on 2011-02-25
 version = "6.x-1.x-dev"
-core = "6.x"
+core = 7.x
 project = "uc_option_image"
 datestamp = "1298620512"
 
diff -up -r uc_option_image/uc_option_image.install uc_option_image/uc_option_image.install
--- uc_option_image/uc_option_image.install	2011-02-24 20:08:33.000000000 -0600
+++ uc_option_image/uc_option_image.install	2011-04-26 20:00:18.000000000 -0500
@@ -1,13 +1,19 @@
 <?php
+/**
+ * @file
+ * Install, update and uninstall functions for the uc_option_image module.
+ *
+ */
+
 
 /**
- * Implementation of hook_install().
+ * Implements hook_install().
  *   Adds default option image to file system.
  */
 function uc_option_image_install() {
-  $default_image_path = drupal_get_path('module', 'uc_option_image') . '/no_image.png'; 
+  $default_image_path = drupal_get_path('module', 'uc_option_image') . '/no_image.png';
   $default_image_name = 'option_image_0_0_0';
-  $file_path = db_result(db_query("SELECT fid from {files} WHERE filename = '%s' AND filepath", $default_image_name, $default_image_path)); 
+  $file_path = db_query("SELECT fid from {files} WHERE filename = :filename AND filepath", array(':filename' => $default_image_name, '' => $default_image_path))->fetchField();
   // Make sure image doesn't already exist in the files table.
   if (!$file_path) {
     $info = image_get_info($default_image_path);
@@ -24,14 +30,19 @@ function uc_option_image_install() {
 }
 
 /**
- * Implementation of hook_uninstall().
+ * Implements hook_uninstall().
  *   Removes default option image to file system and variables.
  */
 function uc_option_image_uninstall() {
   // Remove default option image.
-  $default_image_path = drupal_get_path('module', 'uc_option_image') . '/no_image.png'; 
+  $default_image_path = drupal_get_path('module', 'uc_option_image') . '/no_image.png';
   $default_image_name = 'option_image_0_0_0';
-  db_query("DELETE FROM {files} WHERE filename = '%s' AND filepath = '%s'", $default_image_name, $default_image_path);
+  // TODO Please review the conversion of this statement to the D7 database API syntax.
+  /* db_query("DELETE FROM {files} WHERE filename = '%s' AND filepath = '%s'", $default_image_name, $default_image_path) */
+  db_delete('files')
+  ->condition('filename', $default_image_name)
+  ->condition('filepath', $default_image_path)
+  ->execute();
 
   // Remove variables.
   variable_del('uc_option_image_attributes');
diff -up -r uc_option_image/uc_option_image.module uc_option_image/uc_option_image.module
--- uc_option_image/uc_option_image.module	2011-02-24 20:08:33.000000000 -0600
+++ uc_option_image/uc_option_image.module	2011-04-26 20:00:19.000000000 -0500
@@ -1,149 +1,165 @@
 <?php
-  
+
 /**
-* @file 
-* Provides image upload fields for attribute options.
-* @author Tj Holowaychuk <tj@vision-media.ca/>
-* @link http://vision-media.ca
-*/
+ * @file
+ * Provides image upload fields for attribute options.
+ * @author Tj Holowaychuk <tj@vision-media.ca/>
+ * @link http://vision-media.ca
+ */
 
-// @todo supply 'default' image field when no option images are supplied or 
+// @todo supply 'default' image field when no option images are supplied or
 // no option image attributes are applied to the product
 // @todo create per class / product 'layer' mode allowing z-index to configure a product
 // using layers of PNG images
 
 /* -----------------------------------------------------------------
 
-  Hook Implementations 
+ Hook Implementations
 
------------------------------------------------------------------- */  
+ ------------------------------------------------------------------ */
 
 /**
- * Implementation of hook_perm();
+ * Implements hook_permission();().
  */
-function uc_option_image_perm() {
-  return array('view option images', 'administer option images');
+function uc_option_image_permission() {
+  return array(
+    'view option images' => array(
+      'title' => t('view option images'),
+      'description' => t('TODO Add a description for \'view option images\''),
+    ),
+    'administer option images' => array(
+      'title' => t('administer option images'),
+      'description' => t('TODO Add a description for \'administer option images\''),
+    ),
+  );
 }
 
 /**
- * Implementation of hook_nodeapi().
- */
-function uc_option_image_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
-  switch ($op) {
-    case 'load':  
-      // Load option images
-      // Keep in mind the file 'filename' is a mash of nid/aid/oid
-      $node->option_images = array();
-      $node->option_images_cached = array();
-      $node->attributes = uc_product_get_attributes($node->nid);
-       
-      if ($node->attributes) {
-        $page_size = variable_get('uc_option_image_page_size', 'preview');     
-        $enabled_attributes = variable_get('uc_option_image_attributes', array());
-        foreach($node->attributes as $attribute) {
-          if ($attribute->options && $enabled_attributes[$attribute->aid]) {
-            foreach($attribute->options as $option) {
-              $file = uc_option_image_load($node->nid, $attribute->aid, $option->oid);
-              if ($file && $file->filepath) {
-                $node->option_images[] = $file;
-                // Load imagecached option images
-                if ($page_size != '_original') {
-                  $node->option_images_cached[$option->oid] = imagecache_create_url($page_size, $file->filepath);
-                }
-                else {
-                  $node->option_images_cached[$option->oid] = $file->filepath;
-                }
-              }
+ * Implements hook_node_load().
+ */
+function uc_option_image_node_load($node, $types) {
+  // Load option images
+  // Keep in mind the file 'filename' is a mash of nid/aid/oid
+  $node->option_images = array();
+  $node->option_images_cached = array();
+  $node->attributes = uc_product_get_attributes($node->nid);
+
+  if ($node->attributes) {
+    $page_size = variable_get('uc_option_image_page_size', 'preview');
+    $enabled_attributes = variable_get('uc_option_image_attributes', array());
+    foreach ($node->attributes as $attribute) {
+      if ($attribute->options && $enabled_attributes[$attribute->aid]) {
+        foreach ($attribute->options as $option) {
+          $file = uc_option_image_load($node->nid, $attribute->aid, $option->oid);
+          if ($file && $file->filepath) {
+            $node->option_images[] = $file;
+            // Load imagecached option images
+            if ($page_size != '_original') {
+              $node->option_images_cached[$option->oid] = imagecache_create_url($page_size, $file->filepath);
             }
-          }           
+            else {
+              $node->option_images_cached[$option->oid] = $file->filepath;
+            }
+          }
         }
       }
-      break;
-      
-    case 'view':
-      // @todo issue being invoked so many times?
-      // @todo refactor
-      if (isset($node->content['add_to_cart'])) { 
-        if (user_access('view option images')) {
-          if ($node->option_images) { 
-            $attributes = $node->attributes;          
-            $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'); 
-            $size = $a4 ? $page_size : $teaser_size;
-                   
-            // Pass attributes to uc_option_image to populate JS settings
-            if ($a4) {
-              uc_option_image($node, $attributes, $size); 
-            }
-            
-            // 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;
-            }
-                                       
-            // Load the default image file
-            $file = uc_option_image_load($node->nid, $first_attribute->aid, $default_option);
-                      
-            // 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', $first_attribute->aid, $file, $size);
-            }
-            else {   
-              $image = theme('uc_option_image_no_image', $node, $size);
-            }
-            
-            // Preload images
-            if ($a4) {
-              $preloaded_images = theme('uc_option_image_preloaded', $first_attribute->aid, $node, $size); 
-            }
-            
-            $node->content['option_image'] = array(
+    }
+  }
+}
+
+/**
+ * Implements hook_node_view().
+ */
+function uc_option_image_node_view($node, $view_mode = 'full') {
+  // @todo issue being invoked so many times?
+  // @todo refactor
+  if (isset($node->content['add_to_cart'])) {
+    if (user_access('view option images')) {
+      if ($node->option_images) {
+        $attributes = $node->attributes;
+        $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');
+        $size = $a4 ? $page_size : $teaser_size;
+
+        // Pass attributes to uc_option_image to populate JS settings
+        if ($a4) {
+          uc_option_image($node, $attributes, $size);
+        }
+
+        // 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;
+        }
+
+        // Load the default image file
+        $file = uc_option_image_load($node->nid, $first_attribute->aid, $default_option);
+
+        // Display the image based on teaser/page view
+        // Ensure that original file exists
+        if ($file->filepath && file_exists($file->filepath)) {
+          // TODO Please change this theme call to use an associative array for the $variables parameter.
+          $image = theme('uc_option_image', $first_attribute->aid, $file, $size);
+        }
+        else {
+          $image = theme('uc_option_image_no_image', array('node' => $node, 'size' => $size));
+        }
+
+        // Preload images
+        if ($a4) {
+          // TODO Please change this theme call to use an associative array for the $variables parameter.
+          $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'),
-              );      
-          }
-        }
+              );
       }
-      break;
+    }
   }
 }
 
 /**
- * Implementation of hook_form_alter();
+ * Implements hook_nodeapi().
+ */
+function uc_option_image_nodeapi_OLD(&$node, $op, $a3 = NULL, $a4 = NULL) { }
+
+/**
+ * Implements hook_form_alter();().
  */
 function uc_option_image_form_alter(&$form, &$form_state, $form_id) {
   switch ($form_id) {
     // Attribute options form
-    case 'uc_object_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) { 
+
+        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) { 
+          if ($oids = element_children($form['attributes'][$aid]['options'])) {
+            foreach ($oids as $oid) {
               $file = uc_option_image_load($nid, $aid, $oid);
-              
+
               if (!empty($file)) {
+                // TODO Please change this theme call to use an associative array for the $variables parameter.
                 $form['attributes'][$aid]['options'][$oid]['option_image_preview'] = array(
-                  '#type' => 'markup',                       
+                  '#type' => 'markup',
                   '#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(
@@ -151,40 +167,40 @@ function uc_option_image_form_alter(&$fo
                   '#title' => t('Image'),
                   '#name' => 'files[' . uc_option_image_id($nid, $aid, $oid) . ']',
                   '#size' => 8,
-                  '#default_value' => $file->filename,       
+                  '#default_value' => $file->filename,
                 );
               }
             }
-          } 
-        } 
-        
+          }
+        }
+
         $form['#submit'][] = 'uc_option_image_uc_object_options_form';
         $form['#attributes'] = array('enctype' => 'multipart/form-data');
       }
       break;
-    
-    // Attribute settings form  
+
+      // Attribute settings form
     case 'uc_attribute_admin_settings':
       if (!user_access('administer option images')) {
-        break;     
+        break;
       }
-      
-      $attribute_options = uc_option_image_get_attribute_options(); 
-      
+
+      $attribute_options = uc_option_image_get_attribute_options();
+
       // Ensure we have imagecache presets otherwise
       // display a message so they can create presets first.
       if (!$size_options = uc_option_image_get_size_options()) {
         // Support both locations of imagecache configuration
-        $link = l('admin/settings/imagecache', 'admin/settings/imagecache');
+        $link = l('admin/config/media/imagecache', 'admin/config/media/imagecache');
         drupal_set_message(t('In order to use Option Images you must first create image presets at !link.', array('!link' => $link)));
         break;
       }
-      
+
       $form['#validate'][] = 'uc_option_image_uc_attribute_admin_settings_validate';
       $form['uc_option_image'] = array(
           '#type' => 'fieldset',
           '#title' => t('Option Images'),
-        );    
+        );
       $form['uc_option_image']['uc_option_image_js'] = array(
           '#type' => 'checkbox',
           '#title' => t('Switch Images'),
@@ -209,13 +225,13 @@ function uc_option_image_form_alter(&$fo
               'fade' => t('Fade'),
             ),
           '#default_value' => variable_get('uc_option_image_effect', 'fade'),
-        );     
+        );
       $form['uc_option_image']['uc_option_image_preview_size'] = array(
           '#type' => 'select',
           '#title' => t('Preview Image Size'),
           '#description' => t('Image size to display in the option table when editing a product.'),
           '#options' => $size_options,
-          '#default_value' => variable_get('uc_option_image_preview_size', '_original') ,
+          '#default_value' => variable_get('uc_option_image_preview_size', '_original'),
         );
       $form['uc_option_image']['uc_option_image_teaser_size'] = array(
           '#type' => 'select',
@@ -237,110 +253,110 @@ function uc_option_image_form_alter(&$fo
           '#description' => t('Weight used to determine where the option image will display.'),
           '#default_value' => variable_get('uc_option_image_node_weight', '9'),
         );
-                                              
-      $form['buttons']['#weight'] = 5;        
+
+      $form['buttons']['#weight'] = 5;
       break;
   }
 }
 
 /**
- * Implementation of hook_form_FORM_ID_alter() for the "uc_object_options" form.
+ * Implements hook_form_FORM_ID_alter() for the "uc_object_options" form().
  *
  * This enables us to display the correct image in the shopping cart.
  */
 function uc_option_image_form_uc_cart_view_form_alter(&$form, &$form_state) {
   $imageAttributes            = variable_get('uc_option_image_attributes', '');
   $attributesSameForAllImages = variable_get('uc_option_image_same_image', '');
- 
+
   foreach ($form['#parameters'][2] as $itemId => $cartItem) {
     $nid = $cartItem->nid;
- 
+
     // FIXME: How should we handle more than one attribute with an image? Currently, the last one will take precedence...
     foreach ($cartItem->data['attributes'] as $id => $value) {
- 
+
       if (!empty($imageAttributes[$id])) {
         $optionImage = uc_option_image_load($nid, $id, $value, $attributesSameForAllImages[$id]);
- 
-         // Don't swap product image if we have no image
-         if (!empty($optionImage) && ($optionImage->filename != 'option_image_0_0_0')) {
-           $form['items'][$itemId]['image']['#value'] = uc_option_image_get_cart_picture($optionImage, $nid);
-         }
-       }
-     }
-   }
- }
- 
+
+        // Don't swap product image if we have no image
+        if (!empty($optionImage) && ($optionImage->filename != 'option_image_0_0_0')) {
+          $form['items'][$itemId]['image']['#value'] = uc_option_image_get_cart_picture($optionImage, $nid);
+        }
+      }
+    }
+  }
+}
+
 /* -----------------------------------------------------------------
 
-  General Functionality 
+ General Functionality
 
------------------------------------------------------------------- */
+ ------------------------------------------------------------------ */
 
 /**
  * Add JavaSript and CSS in order to run uc_option_image's switching functionality.
- * 
+ *
  * This function also populates Drupal.settings with uc_option_image filepaths based
  * on $node and $attributes passed.
- * 
+ *
  * @param object $node
  *   Product node object.
- * 
+ *
  * @param array $attributes
  *   Attribute objects.
- * 
+ *
  * @param string $size
- *   (optional) Imagecache preset or '_original'.  
- * 
+ *   (optional) Imagecache preset or '_original'.
+ *
  * @todo: remove $attributes param and just use $node->attributes
  * @todo: abstract out the drupal_add_js so the object can be returned via js http request
  */
 function uc_option_image($node, $attributes, $size = '_original') {
-  static $prep, $data;         
-  
+  static $prep, $data;
+
   // Check if this feature is enabled
   if (!variable_get('uc_option_image_js', TRUE)) {
     return;
-  }  
-  
+  }
+
   // Make sure we are even switching attributes
   if (!variable_get('uc_option_image_attributes', FALSE)) {
-    return;  
-  }   
-                       
+    return;
+  }
+
   // Static prep
-  if (!$prep){
+  if (!$prep) {
     drupal_add_js(drupal_get_path('module', 'uc_option_image') . '/uc_option_image.js');
-    
+
     $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);
+    $data['noimage'] = theme('uc_option_image_no_image_path', array('node' => $node, 'size' => $size));
     $data['attributes'] = variable_get('uc_option_image_attributes', '');
     $data['nodeid'] = $node->nid;
 
     $prep = TRUE;
-  }                             
+  }
 
   $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){
+  // 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 ($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],
-              );     
+              );
           }
         }
       }
@@ -348,67 +364,71 @@ function uc_option_image($node, $attribu
   }
 
   // @todo: fix array_merge_recursive() issues...
-  drupal_add_js(array('UCOI' => $data), 'setting');
-}       
-                          
+  drupal_add_js(array('UCOI' => $data), array('type' => 'setting', 'scope' => JS_DEFAULT));
+}
+
 /**
  * Load image file.
- * 
+ *
  * @todo: static cache
  */
-function uc_option_image_load($nid, $aid, $oid) {
-  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));
+function uc_option_image_load($nids, $aid, $oid) {
+  foreach ($nids as $nid => &$nid) {
+    static $files;
+    $filename = uc_option_image_id($nid, $aid, $oid);
     if (empty($files[$filename])) {
-      if ($nid) {
-        return uc_option_image_load(0, $aid, $oid);
-      }
-      elseif ($aid && $oid) {
-        return uc_option_image_load(0, 0, 0);
+      $files[$filename] = db_fetch_object(db_query("SELECT * FROM {files} WHERE filename = :filename", array(':filename' => $filename)));
+      if (empty($files[$filename])) {
+        if ($nid) {
+          return uc_option_image_load(0, $aid, $oid);
+        }
+        elseif ($aid && $oid) {
+          return uc_option_image_load(0, 0, 0);
+        }
       }
     }
+    foreach ($files[$filename] as $property => &$value) {
+      $nid->$property = $value;
+    }
   }
-  return $files[$filename];
 }
 
 /**
- * Save the uploaded file in the 'option-images' folder and insert 
+ * Save the uploaded file in the 'option-images' folder and insert
  * into the files table.
- * 
+ *
  * @param int $nid
- * 
+ *
  * @param int $aid
- * 
+ *
  * @param int $oid
- * 
+ *
  * @return mixed
  *   - Success: File object
  *   - Failure: FALSE
  */
-function uc_option_image_save($nid, $aid, $oid) { 
+function uc_option_image_save($nid, $aid, $oid) {
   global $user;
   $validators = array(
     'file_validate_size' => array(2 * 1024 * 1024),
     'file_validate_is_image' => array(),
   );
 
-  if ($file = file_save_upload(uc_option_image_id($nid, $aid, $oid),$validators)) {
+  if ($file = file_save_upload(uc_option_image_id($nid, $aid, $oid), $validators)) {
     $dest = file_create_path(file_directory_path() . '/option-images');
-    file_check_directory($dest, FILE_CREATE_DIRECTORY);
+    file_prepare_directory($dest, FILE_CREATE_DIRECTORY);
     if (file_copy($file->filepath, $dest, FILE_EXISTS_REPLACE)) {
-      $file->filename = uc_option_image_id($nid,$aid,$oid);
+      $file->filename = uc_option_image_id($nid, $aid, $oid);
       $file->uid = $user->uid;
       $file->status = FILE_STATUS_PERMANENT;
       uc_option_image_delete($nid, $aid, $oid);
       drupal_write_record('files', $file);
-      
+
       return $file;
     }
     else {
       drupal_set_message(t('Failed to save image.'), 'error');
-      
+
       return FALSE;
     }
   }
@@ -416,18 +436,22 @@ function uc_option_image_save($nid, $aid
 
 /**
  * Delete an option image.
- * 
+ *
  * @param int $nid
- * 
+ *
  * @param int $aid
- * 
+ *
  * @param int $oid
- * 
+ *
  * @return mixed
  *   Results of db_query().
  */
 function uc_option_image_delete($nid, $aid, $oid) {
-  return db_query("DELETE FROM {files} WHERE filename = '%s'", uc_option_image_id($nid,$aid,$oid));    
+  // TODO Please review the conversion of this statement to the D7 database API syntax.
+  /* db_query("DELETE FROM {files} WHERE filename = '%s'", uc_option_image_id($nid, $aid, $oid)) */
+  return db_delete('files')
+  ->condition('filename', uc_option_image_id($nid, $aid, $oid))
+  ->execute();
 }
 
 /**
@@ -435,16 +459,16 @@ function uc_option_image_delete($nid, $a
  */
 function uc_option_image_get_size_options() {
   $options = array('_original' => t('Original'));
-  $presets = imagecache_presets(); 
-  
+  $presets = imagecache_presets();
+
   if (empty($presets)) {
     return FALSE;
   }
-  
-  foreach((array) $presets as$preset){ 
+
+  foreach ((array) $presets as $preset) {
     $options[$preset['presetname']] = $preset['presetname'];
   }
-       
+
   return $options;
 }
 
@@ -453,12 +477,12 @@ function uc_option_image_get_size_option
  */
 function uc_option_image_get_attribute_options() {
   $output = array();
-  
+
   $results = db_query("SELECT aid, name FROM {uc_attributes}");
-  while ($result = db_fetch_array($results)){
+  while ($result = db_fetch_array($results)) {
     $output[$result['aid']] = $result['name'];
   }
-  
+
   return $output;
 }
 
@@ -471,56 +495,56 @@ function uc_option_image_id($nid, $aid, 
 
 /* -----------------------------------------------------------------
 
-  Form Handling 
+ Form Handling
 
------------------------------------------------------------------- */
+ ------------------------------------------------------------------ */
 
 /**
  * Handle uc_object_options_form submit.
  */
 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){
+  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);
-        }                                                             
-      } 
-    } 
-  }    
+        }
+      }
+    }
+  }
 }
 
 /* -----------------------------------------------------------------
 
-  Themes 
+ Themes
 
------------------------------------------------------------------- */
+ ------------------------------------------------------------------ */
 
 /**
- * Implementation of hook_theme()
+ * Implements hook_theme().
  */
 function uc_option_image_theme() {
   return array(
     'uc_option_image' => array(
-      'arguments' => array(
+      'variables' => array(
         'file' => NULL,
         'size' => NULL,
       ),
     ),
     'uc_option_image_preloaded' => array(
-      'arguments' => array(
+      'variables' => array(
         'node' => NULL,
         'size' => NULL,
       ),
     ),
     'uc_option_image_no_image' => array(
-      'arguments' => array(
+      'variables' => array(
         'node' => NULL,
         'size' => NULL,
       ),
     ),
     'uc_option_image_no_image_path' => array(
-      'arguments' => array(
+      'variables' => array(
         'node' => NULL,
         'size' => NULL,
       ),
@@ -542,7 +566,10 @@ function uc_option_image_theme() {
  * @return string
  *   Markup.
  */
-function theme_uc_option_image($aid, $file, $size = '_original') {
+function theme_uc_option_image($variables) {
+  $aid = $variables['file'];
+  $file = $variables['size'];
+  // TODO Number of parameters in this theme funcion does not match number of parameters found in hook_theme.
   $shownoimage = TRUE;
 
   if (!variable_get('uc_option_image_show_noimage', FALSE) && $file->filename == 'option_image_0_0_0') {
@@ -558,10 +585,11 @@ function theme_uc_option_image($aid, $fi
 
   if ($shownoimage) {
     if ($size != '_original') {
+      // TODO Please change this theme call to use an associative array for the $variables parameter.
       $imagecache_image = theme('imagecache', $size, $file->filepath, NULL, NULL, $attributes);
     }
     else {
-      $imagecache_image =  theme('image', $file->filepath, NULL, NULL, $attributes, FALSE);
+      $imagecache_image =  theme('image', array('path' => $file->filepath, 'width' => NULL, 'height' => NULL, 'alt' => $attributes, 'title' => FALSE));
     }
   }
 
@@ -575,52 +603,61 @@ function theme_uc_option_image($aid, $fi
  * Theme option image preloaded images.
  *
  * @param object $node
- * 
+ *
  * @param string $size
  *   (optional) An imagecache preset or '_original'.
- * 
+ *
  * @return string
  *   Markup.
  */
-function theme_uc_option_image_preloaded($aid, $node, $size = '_original') {
+function theme_uc_option_image_preloaded($variables) {
+  $aid = $variables['node'];
+  $node = $variables['size'];
+  // TODO Number of parameters in this theme funcion does not match number of parameters found in hook_theme.
   $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){   
+
+  foreach ((array) $node->option_images as $i => $option_image) {
+    // TODO Please change this theme call to use an associative array for the $variables parameter.
     $output .= theme('uc_option_image', $aid, $option_image, $size);
   }
-  
-  $output .= theme('uc_option_image_no_image', $node, $size);
-  
+
+  $output .= theme('uc_option_image_no_image', array('node' => $node, 'size' => $size));
+
   $output .= '</div>';
-          
+
   return $output;
 }
 
 /**
- * Theme the no image placeholder. 
+ * Theme the no image placeholder.
  */
-function theme_uc_option_image_no_image($node, $size = '_original') {
+function theme_uc_option_image_no_image($variables) {
+  $node = $variables['node'];
+  $size = $variables['size'];
   $attributes = array('class' => 'uc-option-image');
   $filename = path_to_theme() . '/images/noimage.png';
-  
-  if ($size != '_original'){           
+
+  if ($size != '_original') {
+    // TODO Please change this theme call to use an associative array for the $variables parameter.
     return theme('imagecache', $size, $filename, t('No Image'), NULL, $attributes);
   }
-  else {                                                        
-    return theme('image', $filename, t('No Image'), NULL, $attributes, FALSE);
+  else {
+    return theme('image', array('path' => $filename, 'width' => t('No Image'), 'height' => NULL, 'alt' => $attributes, 'title' => FALSE));
   }
 }
 
 /**
  * Theme the no image placeholder. Must be a valid imagepath.
  */
-function theme_uc_option_image_no_image_path($node, $size = '_original') {
+function theme_uc_option_image_no_image_path($variables) {
+  $node = $variables['node'];
+  $size = $variables['size'];
   $filename = drupal_get_path('module', 'uc_option_image') . '/noimage.png';
-  
-  if ($size != '_original'){           
+
+  if ($size != '_original') {
     return imagecache_create_url($size, $filename);
   }
-  else {                                                        
+  else {
     return $filename;
   }
 }
@@ -653,13 +690,14 @@ function uc_option_image_get_cart_pictur
     $path = $optionImage->filepath;
 
     if (file_exists($path)) {
+      // TODO Please change this theme call to use an associative array for the $variables parameter.
       $scaledImage = theme('imagecache', 'cart', $path, $optionImage->alt, $optionImage->title);
 
       if ($format == 'product') {
         if ($imageWidget) {
           $output .=
-            '<a title="'. $optionImage->title .'" href="'. imagecache_create_url('product_full', $path) . '" ' .
-            $imageWidgetFunc(NULL) .'>';
+            '<a title="' . $optionImage->title . '" href="' . imagecache_create_url('product_full', $path) . '" ' .
+            $imageWidgetFunc(NULL) . '>';
         }
 
         $output .= $scaledImage;
@@ -669,7 +707,7 @@ function uc_option_image_get_cart_pictur
         }
       }
       else {
-        $output = l($scaledImage, 'node/'. $nid, array('html' => TRUE));
+        $output = l($scaledImage, 'node/' . $nid, array('html' => TRUE));
       }
     }
   }
@@ -679,13 +717,13 @@ function uc_option_image_get_cart_pictur
 
 /* -----------------------------------------------------------------
 
-  Theme Overrides 
-                                                                                   
------------------------------------------------------------------- */
+ Theme Overrides
+
+ ------------------------------------------------------------------ */
 
 /**
- * Display the option form. 
- * 
+ * Display the option form.
+ *
  * Add our image fields to the table.
  */
 function phptemplate_uc_object_options_form($form) {
@@ -705,11 +743,11 @@ function phptemplate_uc_object_options_f
         $row[] = drupal_render($form['attributes'][$key]['options'][$oid]['weight']);
         $row[] = drupal_render($form['attributes'][$key]['options'][$oid]['ordering']);
         // 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][uc_option_image_id(arg(1), $key, $oid)]);
         $row[] = drupal_render($form['attributes'][$key]['options'][$oid]['option_image_preview']);
-        
+
         if (!$first) {
-          // MOD: changed from -7 to -9 to accomidate the new columns 
+          // MOD: changed from -7 to -9 to accomidate the new columns
           $row = array_pad($row, -9, '');
         }
         else {
@@ -736,7 +774,7 @@ function phptemplate_uc_object_options_f
     );
   }
 
-  $output = theme('table', $header, $rows, array('class' => 'product_attributes'))
+  $output = theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('class' => 'product_attributes')))
           . drupal_render($form);
 
   return $output;
