You are here

function exif_update_2 in Exif 5

Add exif for existing images if they exist.

File

./exif.install, line 81

Code

function exif_update_2() {
  if (!isset($_SESSION['exif_update_2'])) {
    $_SESSION['exif_update_2']['nid'] = 0;
    $_SESSION['exif_update_2']['max'] = db_result(db_query("SELECT MAX(nid) FROM {node} WHERE type = 'image'"));
  }
  $context =& $_SESSION['exif_update_2'];
  $result = db_query_range("SELECT f.* FROM {files} f JOIN {node} n ON n.nid = f.nid\n    WHERE n.type = 'image' AND n.nid > %d AND f.filename = '_original'\n    ORDER BY n.nid DESC", $context['nid'], 0, 20);
  while ($file = db_fetch_object($result)) {
    _update_exif_data($file);
    $context['nid'] = $file->nid;
  }
  if ($context['nid'] < $context['max']) {

    // Approximation of how close to done we are...
    return array(
      '#finished' => $context['nid'] / $context['max'],
    );
  }
  else {
    unset($_SESSION['exif_update_2']);
    return array(
      '#finished' => 1,
    );
  }
}