You are here

function imagepicker_file_download in Image Picker 6.2

Same name and namespace in other branches
  1. 7 imagepicker.module \imagepicker_file_download()

Implementation of hook_file_download().

File

./imagepicker.module, line 838
Enables permitted roles to upload images for insertion into configured nodes.

Code

function imagepicker_file_download($filepath) {
  $imgbasedir = imagepicker_get_files_directory(TRUE);
  $file = $imgbasedir . DIRECTORY_SEPARATOR . $filepath;
  if (file_exists($file) & is_file($file)) {

    // There is a file, and it's in our directory structure. So send it.
    $mimetype = file_get_mimetype($filepath);
    return array(
      'Content-type:' . $mimetype,
    );
  }
  else {
    $path_parts = explode('/', $filepath);
    if ($path_parts[0] == IMAGEPICKER_FILES_DIR) {

      // The file is allegedly in our directory, but doesn't exist.
      return -1;
    }
  }

  // Not our file; let someone else decide.
  return NULL;
}