You are here

function pdf_to_imagefield_check_file in PDF to ImageField 7

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

Helper function to check if file is good to convert pages.

Ensures the settings are valid.

File

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

Code

function pdf_to_imagefield_check_file($file) {

  // Check if variables are in place.
  if (!isset($file->field['widget']['module']) || $file->field['widget']['module'] != 'pdf_to_imagefield') {
    watchdog('pdf_to_imagefield', 'Invalid configuration, %pdf file.', array(
      '%pdf' => $file['filename'],
    ));
    return FALSE;
  }
  if (empty($file->field['widget']['target_imagefield'])) {
    return FALSE;
  }

  // Validate the filepath
  if (empty($file->filepath) || !file_exists($file->filepath)) {
    return FALSE;
  }

  // Return TRUE if otherwise OK.
  return TRUE;
}