You are here

function avatar_selection_file_download in Avatar Selection 6

Same name and namespace in other branches
  1. 5.2 avatar_selection.module \avatar_selection_file_download()
  2. 5 avatar_selection.module \avatar_selection_file_download()
  3. 7 avatar_selection.module \avatar_selection_file_download()

Implementation of hook_file_download().

Ensure that user pictures (avatars) are always downloadable.

Parameters

$file: The path to the file that will be checked if downloadable.

Return value

An array containing the file mime type and size, generated by the array() function, if everything is fine. NULL, if the file is not downloadable.

File

./avatar_selection.module, line 500
The Avatar Selection module allows the user to pick an avatar image from a list already loaded by an administrative user, and to the administrator to disable uploading other avatar files by the user.

Code

function avatar_selection_file_download($file) {
  if (user_access('access content')) {
    $data = explode('/', $file);
    $icon = array_pop($data);
    $folder = implode('/', $data);
    if ('avatar_selection' == $folder) {
      $info = image_get_info(file_create_path($file));
      return array(
        'Content-type: ' . $info['mime_type'],
        'Content-length: ' . $info['file_size'],
      );
    }
    else {
      return NULL;
    }
  }
}