You are here

function image_update_1 in Image 5

Same name and namespace in other branches
  1. 5.2 image.install \image_update_1()

Update 4.5 to 4.6 or later.

File

./image.install, line 20

Code

function image_update_1() {
  if (db_table_exists('image')) {
    if ($result = db_query("SELECT * FROM {image}")) {
      $fields = array(
        'thumb_path' => 'thumbnail',
        'preview_path' => 'preview',
        'image_path' => '_original',
      );
      while ($old_image = db_fetch_object($result)) {
        foreach ($fields as $old => $new) {
          $old_file = '';
          if (file_exists($old_image->{$old})) {
            $old_file = $old_image->{$old};
          }
          else {
            $old_file = file_create_path($old_image->{$old});
          }
          if ($old_file && $old_image->{$old} != '' && db_num_rows(db_query("SELECT fid FROM {files} WHERE nid=%d and filename='%s'", $old_image->nid, $new)) == 0) {
            _image_insert($old_image, $new, $old_file);
          }
        }
      }
    }
  }
  return array();
}