You are here

function exif_nodeapi in Exif 5

Same name and namespace in other branches
  1. 6 exif.module \exif_nodeapi()

Implementation of hook_nodeapi().

File

./exif.module, line 26

Code

function exif_nodeapi(&$node, $op, $teaser) {
  if ($teaser || $node->type != 'image') {
    return;
  }
  switch ($op) {
    case 'insert':
    case 'update':
      $file = db_fetch_object(db_query("SELECT * FROM {files} WHERE filepath = '%s'", $node->images[IMAGE_ORIGINAL]));
      _update_exif_data($file);
      break;
    case 'load':
      $fid = db_result(db_query("SELECT fid FROM {files} WHERE filepath = '%s'", $node->images[IMAGE_ORIGINAL]));
      return array(
        'exif_data' => _exif_get_exif($fid),
      );
    case 'view':
      $node->content['exif'] = array(
        '#value' => theme('exif_table', $node),
        '#weight' => 10,
      );
      break;
  }
}