You are here

function avatar_selection_file_download in Avatar Selection 5

Same name and namespace in other branches
  1. 5.2 avatar_selection.module \avatar_selection_file_download()
  2. 6 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.

File

./avatar_selection.module, line 660

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;
    }
  }
}