You are here

function pdf_to_imagefield_node_insert in PDF to ImageField 7

Same name and namespace in other branches
  1. 6.2 pdf_to_imagefield.module \pdf_to_imagefield_node_insert()

hook_node_insert() nodapi subroutine

Check to see if this node has a pdf file that needs processing now that the initial save is done.

This is a brand new node, with a fresh nid

File

./pdf_to_imagefield.module, line 314
PDF to ImageField core hooks and menu callbacks.

Code

function pdf_to_imagefield_node_insert(&$node) {
  $type = content_types($node->type);
  $source_filefield_def = pdf_to_imagefield_source_filefield($node);
  $source_filefield = $source_filefield_def['field_name'];
  $target_imagefield = $source_filefield_def['widget']['target_imagefield'];
  $target_imagefield_def = $type['fields'][$target_imagefield];

  // Is the source filefield full and the target image holder empty?
  if (!pdf_to_imagefield_empty_filefield($node->{$source_filefield}) && pdf_to_imagefield_empty_filefield($node->{$target_imagefield})) {

    // Select the pdf entry(s?) in the specified filefield.
    foreach ($node->{$source_filefield} as $pdf_file) {
      if ($target_imagefield_def['multiple']) {

        // Add this job to the queue. Needed to run post-save so we can tell the batch call about the nid.
        pdf_to_imagefield_set_batch($node, $pdf_file, $source_filefield_def);
      }
    }
  }
}