Index: imagecache.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/imagecache/imagecache.module,v
retrieving revision 1.19.2.15.2.10
diff -u -r1.19.2.15.2.10 imagecache.module
--- imagecache.module	19 Apr 2007 23:03:55 -0000	1.19.2.15.2.10
+++ imagecache.module	10 May 2007 21:11:12 -0000
@@ -238,18 +238,27 @@
  * Implementation of hook_field_formatter().
  */
 function imagecache_field_formatter($field, $item, $formatter) {
-  if (!isset($item['fid'])) {
-    return '';
+  // Load full field definitions for this field instance. Views
+  // doesn't do it. So we can't get the default image if we need it.
+  if (!isset($field['widget']['type'])) {
+    $field = module_invoke('content', 'fields', $field['field_name'], $field['type_name']);
+  }
+
+  // If there is no image on the database, use the default one.
+  if (empty($item['fid']) && $field['widget']['use_default_image'] && is_array($field['widget']['default_image'])) {
+    $item = array_merge($item, $field['widget']['default_image']);
   }
   // Views does not load the file for us, while CCK display fields does.
-  if (!isset($item['filepath'])) {
-    $file = _imagecache_file_load($item['fid']);
-    $item = array_merge($item, $file);
-  }
-  $rules = _imagecache_get_presets();
-  $formatter_check = preg_replace('/_linked$/', '', $formatter);
-  if (in_array($formatter_check, (array) $rules)) {
-    return theme('imagecache_formatter', $field, $item, $formatter);
+  elseif (!isset($item['filepath'])) {
+    $item = array_merge($item, _imagecache_file_load($item['fid']));    
+  }
+  
+  if (!empty($item['filepath'])) {
+    $rules = _imagecache_get_presets();
+    $formatter_check = preg_replace('/_linked$/', '', $formatter);
+    if (in_array($formatter_check, (array) $rules)) {
+      return theme('imagecache_formatter', $field, $item, $formatter);
+    }
   }
 }
 
