Index: imagefield.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/imagefield/imagefield.install,v
retrieving revision 1.2.4.1
diff -u -p -r1.2.4.1 imagefield.install
--- imagefield.install	18 Apr 2007 21:02:19 -0000	1.2.4.1
+++ imagefield.install	7 Oct 2008 14:34:56 -0000
@@ -73,6 +73,28 @@ function imagefield_update_2() {
   return $ret;
 }
 
-
+/**
+ * Change default formatter key from 'default' to 'imagefield_default'.
+ */
+function imagefield_update_3() {
+  $ret = array();
+  include_once(drupal_get_path('module', 'content') .'/content.module');
+  $result = db_query("SELECT field_name, type_name, display_settings FROM {node_field_instance} WHERE widget_type = 'image'");
+  while ($row = db_fetch_array($result)) {
+    $needs_update = FALSE;
+    $display_settings = unserialize($row['display_settings']);
+    foreach (_content_admin_display_contexts() as $context) {
+      if ($display_settings[$context]['format'] == 'default') {
+        $display_settings[$context]['format'] = 'imagefield_default';
+        $needs_update = TRUE;
+      }
+    }
+    if ($needs_update) {
+      db_query("UPDATE {node_field_instance} SET display_settings = '%s' WHERE type_name = '%s' AND field_name = '%s'", serialize($display_settings), $row['type_name'], $row['field_name']);
+    }
+  }
+  content_clear_type_cache();
+  return $ret;
+}
 
 
