Index: thickbox.module
===================================================================
--- thickbox.module	(revision 2)
+++ thickbox.module	(revision 8)
@@ -171,10 +171,30 @@ function thickbox_field_formatter_info()
  */
 function thickbox_field_formatter($field, $item, $formatter) {
   if (module_exists('imagefield') && module_exists('imagecache')) {
-    if (empty($item['fid'])) {
+  	// Must check filepath also because of bug(?) in imagefield
+    if (empty($item['fid']) || !isset($item['filepath'])) {
       return '';
     }
-    $file = _imagefield_file_load($item['fid']);
+    // For Thickboxing on previews
+    if ($item['fid'] == "upload") {
+      $file = $item;
+      $image_path = "";
+      if (!empty($field['widget']['image_path'])) {
+      	// Taken from imagefield 2.x for token support	
+        if (function_exists('token_replace')) {
+          // use tokenized paths if token module is installed.
+          global $user;
+          $image_path = token_replace($field['widget']['image_path'], 'user', $user).'/';
+        }
+        else {
+          $image_path = $field['widget']['image_path'].'/';
+        }
+	  }
+      $file['filepath'] = file_directory_path()."/".$image_path.$file['filename'];
+    }
+    else {
+	  $file = _imagefield_file_load($item['fid']);
+	}
     if (strpos($formatter, 'thickbox][') !== false) {
       list($null, $namespace) = explode('][', $formatter, 2);
       $rules = _imagecache_get_presets();
