diff --git a/uc_option_image.module b/uc_option_image.module
index 05e00e5..4cd8b3d 100644
--- a/uc_option_image.module
+++ b/uc_option_image.module
@@ -66,8 +66,7 @@ function uc_option_image_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
         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);
+            $first_attribute = uc_option_image_get_default_attribute($node->nid, $attributes);
             $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;
@@ -508,6 +507,34 @@ function uc_option_image_id($nid, $aid, $oid) {
   return 'option_image_' . $nid . '_' . $aid . '_' . $oid;
 }
 
+/**
+ * Helper function to get the default attribute from the available attributes.
+ * It runs through the attributes in order and the first one that has an image
+ * for the default option is returned.
+ * If no attributes have an image for the deafult option, the first attribute
+ * is returned.
+ *
+ * @param $nid
+ *   The node ID of the product node.
+ * @param $attributes
+ *   An array of attributes for the product.
+ *
+ * @return
+ *   An attribute object.
+ */
+function uc_option_image_get_default_attribute($nid, $attributes) {
+  foreach ($attributes as $attribute) {
+    if (!empty($attribute->default_option)) {
+      $file = uc_option_image_load($nid, $attribute->aid, $attribute->default_option);
+      if ($file->filename != 'option_image_0_0_0' && $file->filepath && file_exists($file->filepath)) {
+        return $attribute;
+      }
+    }
+  }
+  return array_shift($attributes);
+}
+
+
 /* -----------------------------------------------------------------
 
   Form Handling
