You are here

function imagefield_update_4 in ImageField 5.2

Change default formatter back from 'imagefield_default' to 'default'.

CCK always makes the default formatter "default". It's best not to fight it and make our default the same.

File

./imagefield.install, line 84

Code

function imagefield_update_4() {
  $ret = array();
  include_once drupal_get_path('module', 'content') . '/content.module';
  include_once drupal_get_path('module', 'content') . '/content_admin.inc';
  $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'] == 'imagefield_default' || empty($display_settings[$context]['format'])) {
        $display_settings[$context]['format'] = '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;
}