function avatar_selection_file_download in Avatar Selection 7
Same name and namespace in other branches
- 5.2 avatar_selection.module \avatar_selection_file_download()
- 5 avatar_selection.module \avatar_selection_file_download()
- 6 avatar_selection.module \avatar_selection_file_download()
Implements 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 645 - 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_prepare_directory($file));
return array(
'Content-type: ' . $info['mime_type'],
'Content-length: ' . $info['file_size'],
);
}
else {
return NULL;
}
}
}