--- thickbox.module	2007-01-25 23:48:20.000000000 +0100
+++ thickbox.module.imagefield_0	2007-01-26 00:11:11.000000000 +0100
@@ -55,3 +55,49 @@ function thickbox_menu($may_cache) {
 
   return $items;
 }
+
+/**
+ * Implementation of hook_field_formatter_info().
+ * Adds certain thickbox+imagecache formatters to CCK image fields if imagefield.module and imagecache.module exist.
+ */
+function thickbox_field_formatter_info() {
+  $formatter = array();
+  if ( module_exists('imagefield') && module_exists('imagecache') ) {
+    $rules = _imagecache_get_presets();
+    foreach ($rules as $ruleid => $rulename) {
+      $formatters['thickbox]['.$rulename] = array(
+        'label' => 'Thickbox: '.$rulename,
+        'field types' => array('image'),
+        );
+    }
+  }
+  return $formatters;
+}
+
+/**
+ * Implementation of hook_field_formatter().
+ */
+function thickbox_field_formatter($field, $item, $formatter) {
+  if ( module_exists('imagefield') && module_exists('imagecache') ) {
+    if (!isset($item['fid'])) {
+      return '';
+    }
+    $file = _imagefield_file_load($item['fid']);
+    if (strpos($formatter, 'thickbox][') !== false) {
+      list($null, $namespace) = explode('][', $formatter, 2);
+      $rules = _imagecache_get_presets();
+      if (in_array($namespace, (array) $rules)) {
+        return theme('imagefield_image_imagecache_thickbox', $namespace, $field, $file['filepath'], $item['alt'], $item['title']);
+      }
+    }
+  }
+}
+
+/**
+ * Implementation of theme_imagefield_image_imagecache_thickbox().
+ */
+function theme_imagefield_image_imagecache_thickbox($namespace, $field, $path, $alt = '', $title = '', $attributes = NULL) {
+  $attributes = drupal_attributes($attributes);
+  $imagecache_path =  file_create_url(file_directory_path() .'/imagecache/'. $namespace .'/'. $path);
+  return '<a href="'. check_url(file_create_url($path)) .'" class="thickbox" rel="'. $field['type_name'] .'"><img src="'. check_url($imagecache_path) .'" alt="'. check_plain($alt) .'" title="'. check_plain($title) .'" '. $attributes .' /></a>';
+}
\ Kein Zeilenumbruch am Dateiende.
