You are here

function ctools_file_download in Chaos Tool Suite (ctools) 6

Same name and namespace in other branches
  1. 7 ctools.module \ctools_file_download()

Implementation of hook_file_download()

When using the private file system, we have to let Drupal know it's ok to download CSS and image files from our temporary directory.

File

./ctools.module, line 474
CTools primary module file.

Code

function ctools_file_download($filepath) {
  if (strpos($filepath, 'ctools') === 0) {
    $mime = file_get_mimetype($filepath);

    // For safety's sake, we allow only text and images.
    if (strpos($mime, 'text') === 0 || strpos($mime, 'image') === 0) {
      return array(
        'Content-type:' . $mime,
      );
    }
  }
}