Index: imagefield.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/imagefield/imagefield.module,v
retrieving revision 1.9.2.1
diff -u -r1.9.2.1 imagefield.module
--- imagefield.module	1 Sep 2006 22:08:32 -0000	1.9.2.1
+++ imagefield.module	13 Sep 2006 09:50:36 -0000
@@ -175,7 +175,7 @@
       foreach ($node_field as $delta => $item) {
         // do not show images flagged for deletion in preview.
         if (!$item['flags']['delete'] == 1) {
-          $node_field[$delta]['view'] = theme('imagefield_image', $item); 
+          $node_field[$delta]['view'] = content_format($field, $item, 'default'); 
           $images[] =  $node_field[$delta]['view'];
         }
       }
@@ -461,9 +461,49 @@
   return $form;
 }
 
-function imagefield_field_view_item($field, $node_field_item) {
-    $file = _imagefield_file_load($node_field_item['fid']);
-    return theme('imagefield_view_image', $file, $node_field_item['alt'], $node_field_item['title']); 
+/**
+ * Implementation of hook_field_formatter_info().
+ */
+function imagefield_field_formatter_info() {
+  $formatters = array(
+    'default' => array(
+      'label' => 'Default',
+      'field types' => array('image'),
+    ),
+  );
+  if (module_exist('imagecache')) {
+    $rules = _imagecache_get_presets();
+    foreach ($rules as $ruleid => $rulename) {
+       $formatters[$rulename] = array(
+         'label' => $rulename,
+         'field types' => array('image'),
+         );
+    }
+  }
+  return $formatters;
+}
+
+/**
+ * Implementation of hook_field_formatter().
+ *
+ */
+function imagefield_field_formatter($field, $item, $formatter) {
+  if (!isset($item['fid'])) {
+    return '';
+  }
+  $rules = array();
+  if (module_exist('imagecache')) {
+    $rules = _imagecache_get_presets();
+  }
+  if (!in_array($formatter, $rules)) {
+    $formatter = 'default';
+  }
+  if ($formatter != 'default') {
+    $rulepath = 'files/imagecache/'. $formatter .'/';
+  }
+  $file = _imagefield_file_load($item['fid']);
+  return theme('imagefield_image', $file, '', '', NULL, TRUE, $rulepath);
+
 }
 
 
@@ -509,8 +549,12 @@
   return $output;  
 }
 
-function theme_imagefield_image($file, $alt = '', $title = '', $attributes = NULL, $getsize = TRUE) {
+function theme_imagefield_image($file, $alt = '', $title = '', $attributes = NULL, $getsize = TRUE, $rulepath = NULL) {
+  
   $file = (array)$file;
+  if ($rulepath) {
+     $file['filepath'] = $rulepath . $file['filepath'];
+  }
   if (!$getsize || (is_file($file['filepath']) && (list($width, $height, $type, $image_attributes) = @getimagesize($file['filepath'])))) {
     $attributes = drupal_attributes($attributes);
     if ($file['fid'] == 'upload') {
@@ -520,6 +564,7 @@
       $path = $file['filepath'];
     }
     $url = file_create_url($path);
+    
     if ($alt == '') {
       $alt = $file['alt'];
     }
