You are here

function pdf_to_imagefield_attach_files in PDF to ImageField 7

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

Attach the list of files to the given node and save it.

2 calls to pdf_to_imagefield_attach_files()
pdf_to_imagefield_attach_pages_batched in ./pdf_to_imagefield.module
Attach files to a node, as a batch callback.
pdf_to_imagefield_process_pdf in ./pdf_to_imagefield.module
Given an node and a PDF file to process, do so.

File

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

Code

function pdf_to_imagefield_attach_files($images, $node, $field_name) {
  if (count($images)) {
    foreach ($images as $image) {
      $image->list = FALSE;

      // CCK complains a little if there is no -> data array at all.
      $image->data = array();
      $node->{$field_name}[] = (array) $image;
    }
    node_save($node);
    watchdog('pdf_to_imagefield', '%images files attached to %title node.', array(
      '%images' => count($images),
      '%title' => $node->title,
    ));
  }
  else {
    watchdog('pdf_to_imagefield', 'No files attached to %title node.', array(
      '%title' => $node->title,
    ), WATCHDOG_ERROR);
  }
}