You are here

function _video_image_temp_image_store in Video 6

Same name and namespace in other branches
  1. 5 plugins/video_image/video_image.module \_video_image_temp_image_store()
  2. 6.2 plugins/video_image/video_image.module \_video_image_temp_image_store()
3 calls to _video_image_temp_image_store()
_video_image_prepare in plugins/video_image/video_image.module
_video_image_presave in plugins/video_image/video_image.module
_video_image_regenerate_thumbnail in plugins/video_image/video_image.module

File

plugins/video_image/video_image.module, line 417
video_image.module

Code

function _video_image_temp_image_store(&$file) {

  // Update the node to reflect the actual filename, it may have been changed
  $image = new stdClass();
  $image->images[IMAGE_ORIGINAL] = $file->filepath;

  //using image module
  $image->images = _image_build_derivatives($image);
  $image->type = 'image';
  $image->uid = 1;
  $image->created = time();
  $image->title = t('video image thumbnail');

  // We're good to go.
  $image->rebuild_images = FALSE;
  $image->new_file = TRUE;

  //print_r($image);

  //exit;
  if ($image->images) {
    node_validate($image);
    if (!form_get_errors()) {

      // save the images in the files table
      foreach ($image->images as $l => $f) {
        $info = image_get_info($f);
        $original_path = $node->images[IMAGE_ORIGINAL];
        if (file_move($file->filepath, _image_filename($original_path, $size))) {
          $file->fid = db_last_insert_id('files', 'fid');
          db_query("INSERT INTO {files} (fid, filename, filepath, filemime, filesize) VALUES (%d, '%s', '%s', '%s', '%s')", $fid, "video_image_temp.{$l}", $f, $info['mime_type'], $info['file_size']);
        }
        $image->fids[$l] = $file->fid;
      }
    }
  }

  //print_r($image);

  //exit;
  return (array) $image;
}