Index: colorbox.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/colorbox/colorbox.admin.inc,v
retrieving revision 1.7
diff -u -p -r1.7 colorbox.admin.inc
--- colorbox.admin.inc	13 Apr 2010 16:20:00 -0000	1.7
+++ colorbox.admin.inc	15 Apr 2010 18:25:23 -0000
@@ -45,12 +45,24 @@ function colorbox_admin_settings() {
       '#title' => t('Image module settings'),
     );
     $form['colorbox_image_module']['colorbox_auto_image_nodes'] = array(
-      '#type' => 'select',
+      '#type' => 'radios',
       '#title' => t('Image node setting'),
-      '#options' => array(0 => t('Disabled'), 1 => t('Colorbox')),
+      '#options' => array(0 => t('Disabled'), 1 => t('Enabled')),
       '#default_value' => variable_get('colorbox_auto_image_nodes', 0),
       '#description' => t('Select if Colorbox should be activated for the Image module.'),
     );
+    $derivative_options = array();
+    $sizes = image_get_sizes();
+    foreach ($sizes as $label => $size) {
+      $derivative_options[$label] = $size['label'];
+    }
+    $form['colorbox_image_module']['colorbox_image_derivative'] = array(
+      '#type' => 'select',
+      '#title' => t('Image derivative'),
+      '#options' => $derivative_options,
+      '#default_value' => variable_get('colorbox_image_derivative', 'preview'),
+      '#description' => t('Select which image derivative to load in the Colorbox.'),
+    );
   }
 
   $form['colorbox_login_settings'] = array(
Index: colorbox.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/colorbox/colorbox.module,v
retrieving revision 1.11
diff -u -p -r1.11 colorbox.module
--- colorbox.module	12 Apr 2010 14:49:27 -0000	1.11
+++ colorbox.module	15 Apr 2010 18:25:23 -0000
@@ -173,6 +173,16 @@ function _colorbox_doheader() {
   }
   drupal_add_js(array('colorbox' => $js_settings), 'setting');
 
+  if (module_exists('image') && variable_get('colorbox_auto_image_nodes', 0)) {
+    $image_derivative = variable_get('colorbox_image_derivative', 'preview');
+    // If the image derivative is set to IMAGE_ORIGINAL check if the
+    // user has access before activating Colorbox.
+    if (!($image_derivative == IMAGE_ORIGINAL && !user_access('view original images'))) {
+      drupal_add_js(array('colorbox' => array('image_derivative' => $image_derivative)), 'setting');
+      drupal_add_js($path .'/js/colorbox_image_module.js');
+    }
+  }
+
   $colorbox_file = array('none' => 'jquery.colorbox.js', 'min' => 'jquery.colorbox-min.js');
   drupal_add_js(variable_get('colorbox_path', COLORBOX_PATH) .'/colorbox/'. $colorbox_file[variable_get('colorbox_compression_type', 'min')]);
   drupal_add_js($path .'/js/colorbox.js');
@@ -181,10 +191,6 @@ function _colorbox_doheader() {
     drupal_add_js($path .'/js/colorbox_default_style.js');
   }
 
-  if (module_exists('image') && variable_get('colorbox_auto_image_nodes', 0)) {
-    drupal_add_js($path .'/js/colorbox_image_module.js');
-  }
-
   if (variable_get('colorbox_form', 0)) {
     drupal_add_js($path .'/js/colorbox_form.js');
   }
@@ -212,19 +218,13 @@ function colorbox_form_alter(&$form, $fo
  * Implementation of hook_link_alter().
  */
 function colorbox_link_alter(&$links, $node) {
-  if ($node->type != 'image') {
-    return;
-  }
-  $sizes = array(
-    '_original',
-    'preview',
-    'thumbnail',
-  );
-  // Add a colorbox class to the image link sizes on the image node.
-  foreach ($sizes as $size) {
-    $links['image_size_'. $size]['attributes']['class'] = "image image-{$size} colorbox";
-    $links['image_size_'. $size]['href'] = $node->images[$size];
-    unset($links['image_size_'. $size]['query']);
+  if ($node->type == 'image' && variable_get('colorbox_auto_image_nodes', 0)) {
+    // Add a colorbox class to the image link sizes on the image node.
+    foreach ($node->images as $size => $path) {
+      $links['image_size_'. $size]['attributes']['class'] = "image image-{$size} colorbox";
+      $links['image_size_'. $size]['href'] = $path;
+      unset($links['image_size_'. $size]['query']);
+    }
   }
 }
 
Index: js/colorbox_image_module.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/colorbox/js/colorbox_image_module.js,v
retrieving revision 1.2
diff -u -p -r1.2 colorbox_image_module.js
--- js/colorbox_image_module.js	3 Apr 2010 08:39:19 -0000	1.2
+++ js/colorbox_image_module.js	15 Apr 2010 18:25:23 -0000
@@ -1,12 +1,32 @@
 // $Id: colorbox_image_module.js,v 1.2 2010/04/03 08:39:19 frjo Exp $
 Drupal.behaviors.initColorboxImageModule = function (context) {
+  var settings = Drupal.settings.colorbox;
+
   // Image Attach Functionality
-  $('.image-attach-body > a', context).each(function (i) {
-    // Modify link to jpg
-    this.href = $('.image-attach-body > a > img:eq('+i+')').attr("src").replace(".thumbnail", "");
+  $('div.image-attach-body > a, ul.images a', context).filter(':not(.initColorboxImageModule-processed)').addClass('initColorboxImageModule-processed').each(function (i) {
+    var $img = $('.image', this);
+    if ($img.length === 0) {
+      return true;
+    }
+
+    // Find derivative
+    var matches = $img.attr('class').match(/image\-(\w+)/);
+    if (matches === null) {
+      return true;
+    }
+    var derivative = matches[1];
+
+    // Create link path
+    var path_replacement = settings.image_derivative == '_original' ? '' : '.' + settings.image_derivative;
+    var href = $img.attr('src').replace('.' + derivative, path_replacement);
+
+    // Modify link to image
+    this.href = href;
     // Add rel tag to group
-    this.rel = "image-gallery";
+    this.rel = 'image-gallery';
+    // Add image link title
+    this.title = $img.attr('title');
     // Colorbox it
+    $(this).addClass('colorbox');
   });
-  $("a[rel='image-gallery']", context).colorbox();
 };
