# This patch file was generated by NetBeans IDE
# It uses platform neutral UTF-8 encoding and \n newlines.
--- /colorbox/colorbox.theme.inc
+++ /colorbox/colorbox.theme.inc
@@ -112,19 +112,36 @@
   return l($image, $variables['path'], $options);
 }
 
+
+/*
+ * Inspiried by insert_create_url(). Cuts off base url if variable is set and makes links relative.
+ */
+function colorbox_relative_url($url) {
+  // use insert.module's variable
+  $absolute = variable_get('insert_absolute_paths', TRUE);
+
+  if ($absolute) {
+    return $url;
+  } else {
+    return str_replace($GLOBALS['base_url'], '', $url);
+  }
+}
+
+
 /**
  * Preprocess variables for the colorbox-insert-image.tpl.php file.
  */
 function template_preprocess_colorbox_insert_image(&$variables) {
+  
   $file = file_load($variables['item']['fid']);
 
-  $variables['image_path'] = image_style_url($variables['item']['style_name'], $file->uri);
+  $variables['image_path'] = colorbox_relative_url(image_style_url($variables['item']['style_name'], $file->uri));
 
   if ($style_name = variable_get('colorbox_image_style', '')) {
-    $variables['link_path'] = image_style_url($style_name, $file->uri);
+    $variables['link_path'] = colorbox_relative_url(image_style_url($style_name, $file->uri));
   }
   else {
-    $variables['link_path'] = file_create_url($file->uri);
+    $variables['link_path'] = colorbox_relative_url(file_create_url($file->uri));
   }
 
   $variables['class'] = $variables['widget']['settings']['insert_class'];

