You are here

function pdf_to_imagefield_save_converted in PDF to ImageField 6

Same name and namespace in other branches
  1. 6.2 pdf_to_imagefield.module \pdf_to_imagefield_save_converted()
  2. 7 pdf_to_imagefield.module \pdf_to_imagefield_save_converted()

Save converted images as ImageField files

1 call to pdf_to_imagefield_save_converted()
pdf_to_imagefield_cron in ./pdf_to_imagefield.module
Implementation of hook_cron().

File

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

Code

function pdf_to_imagefield_save_converted($images, $field, $pdf) {
  foreach (filefield_get_file_references($pdf) as $nid => $vid) {
    $node = node_load($nid);
    if (count($images)) {
      foreach ($images as $image) {

        #$image->list = FALSE;
        $node->{$field['field_name']}[] = (array) $image;
      }
      node_save($node);
      watchdog('pdf_to_imagefield', '%images pdf previews generated to %title node from %pdf file.', array(
        '%images' => count($images),
        '%title' => $node->title,
        '%pdf' => $pdf['filename'],
      ));
    }
    else {
      watchdog('pdf_to_imagefield', 'No pdf previews generated to %title node from %pdf file. But it is still in cron list.', array(
        '%title' => $node->title,
        '%pdf' => $pdf['filename'],
      ), WATCHDOG_ERROR);
    }
  }
}