Skip to content
Snippets Groups Projects
Commit 0b876c44 authored by Dries Buytaert's avatar Dries Buytaert
Browse files

- Patch #6425 by TDobes: made avatars work with private download method.  Added
  user_file_download() function to communicate with the file system layer.
parent 76c4be31
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -324,6 +324,31 @@ function user_perm() {
return array("administer users", "access user list");
}
function user_file_download($file) {
if (strpos($file, variable_get('user_picture_path', "pictures") . FILE_SEPARATOR . 'picture-') === 0) {
list($width, $height, $type, $attr) = getimagesize(file_create_path($file));
$types = array(
IMAGETYPE_GIF => 'image/gif',
IMAGETYPE_JPEG => 'image/jpeg',
IMAGETYPE_PNG => 'image/png',
IMAGETYPE_SWF => 'application/x-shockwave-flash',
IMAGETYPE_PSD => 'image/psd',
IMAGETYPE_BMP => 'image/bmp',
IMAGETYPE_TIFF_II => 'image/tiff',
IMAGETYPE_TIFF_MM => 'image/tiff',
IMAGETYPE_JPC => 'application/octet-stream',
IMAGETYPE_JP2 => 'image/jp2',
IMAGETYPE_JPX => 'application/octet-stream',
IMAGETYPE_JB2 => 'application/octet-stream',
IMAGETYPE_SWC => 'application/x-shockwave-flash',
IMAGETYPE_IFF => 'image/iff',
IMAGETYPE_WBMP => 'image/vnd.wap.wbmp',
IMAGETYPE_XBM => 'image/xbm'
);
return array('Content-type: '. $types[$type]);
}
}
function user_search($keys) {
$find = array();
$result = db_query_range("SELECT * FROM {users} WHERE name LIKE '%%%s%%'", $keys, 0, 20);
......
......@@ -324,6 +324,31 @@ function user_perm() {
return array("administer users", "access user list");
}
function user_file_download($file) {
if (strpos($file, variable_get('user_picture_path', "pictures") . FILE_SEPARATOR . 'picture-') === 0) {
list($width, $height, $type, $attr) = getimagesize(file_create_path($file));
$types = array(
IMAGETYPE_GIF => 'image/gif',
IMAGETYPE_JPEG => 'image/jpeg',
IMAGETYPE_PNG => 'image/png',
IMAGETYPE_SWF => 'application/x-shockwave-flash',
IMAGETYPE_PSD => 'image/psd',
IMAGETYPE_BMP => 'image/bmp',
IMAGETYPE_TIFF_II => 'image/tiff',
IMAGETYPE_TIFF_MM => 'image/tiff',
IMAGETYPE_JPC => 'application/octet-stream',
IMAGETYPE_JP2 => 'image/jp2',
IMAGETYPE_JPX => 'application/octet-stream',
IMAGETYPE_JB2 => 'application/octet-stream',
IMAGETYPE_SWC => 'application/x-shockwave-flash',
IMAGETYPE_IFF => 'image/iff',
IMAGETYPE_WBMP => 'image/vnd.wap.wbmp',
IMAGETYPE_XBM => 'image/xbm'
);
return array('Content-type: '. $types[$type]);
}
}
function user_search($keys) {
$find = array();
$result = db_query_range("SELECT * FROM {users} WHERE name LIKE '%%%s%%'", $keys, 0, 20);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment