You are here

function photos_image_date in Album Photos 7.3

Same name and namespace in other branches
  1. 6.2 photos.module \photos_image_date()

Image written to database.

3 calls to photos_image_date()
photos_swfu_upload in photos_swfu/photos_swfu.module
Upload photos with SWFUpload.
photos_upload_form_submit in inc/photos.edit.inc
Submit upload form.
_photos_unzip in ./photos.module
Unzip.

File

./photos.module, line 1648
Implementation of photos.module.

Code

function photos_image_date($file, $title = 0) {
  $exif = $file->filemime == 'image/jpeg' ? 1 : 0;
  if (isset($file->fid) && isset($file->pid)) {
    $fid = $file->fid;
    $pid = $file->pid;
    db_merge('photos_image')
      ->key(array(
      'fid' => $file->fid,
    ))
      ->fields(array(
      'pid' => $file->pid,
      'title' => isset($file->title) ? $file->title : $file->filename,
      'des' => isset($file->des) ? $file->des : '',
      'wid' => isset($file->wid) ? $file->wid : 0,
      'comcount' => 0,
      'count' => 0,
      'exif' => $exif,
    ))
      ->execute();
  }
  if (isset($fid) && !empty($fid)) {
    if (isset($file->nid)) {
      db_insert('photos_node')
        ->fields(array(
        'nid' => $file->nid,
        'fid' => $file->fid,
      ))
        ->execute();
    }
    if (variable_get('photos_user_count_cron', 1)) {
      global $user;
      photos_set_count('user_image', isset($file->uid) ? $file->uid : $user->uid);
      photos_set_count('node_album', $file->pid);
      isset($file->nid) ? photos_set_count('node_node', $file->nid) : NULL;
    }
    $file->status = 1;
    $file = file_save($file);
    file_usage_add($file, 'photos', 'node', $pid);
    if ($photos_size_max = variable_get('photos_size_max', '')) {
      file_validate_image_resolution($file, $photos_size_max);
    }
    return TRUE;
  }
  else {
    return FALSE;
  }
}