The new user module by Dries (good work by the way !) changed avatars to pictures. Strangely enough the (newly) uploaded pictures didn't display, just the ALT text (Opera 7.23 / Mozilla 1.6, Drupal cvs, Xtemplate theme, FreeBSD 4.9)
TDobes found a typo: see http://drupal.org/node/view/6406. But the picture's still didn't display.
Looking at the html source the img tag was 'malformed':
img src="?q=system/files&file=pictures/picture-1.jpg" alt="koorneef's picture"
The path to the files/pictures/photo.jpg dir was scrambled. I looked first for clues in the theme but couldn't find any leads. In the user.module file the file_create_url(); function is used to format the path to the picture. When I just removed this function call, everything was okidoki.
After reading includes/file.inc I understand that file_create_url() has something to do with the public/private downloading of files (by the way, the user.module is the only (core) module using this function ... yet ?). I use the private downloads setting (not very sure why, but ok).
The patch changes:
- return url('system/files', 'file='. $path);
+ return variable_get('file_directory_path', 'files').'/'.$path;
The url() function call messes up the path to the file, my version seems more logical and ... works for me !
I hope this patch makes any sense, it's my first ;-)
Lucas Koorneef
Comment | File | Size | Author |
---|---|---|---|
#2 | user-picture-private-download.patch | 1.53 KB | TDobes |
file.inc.file_create_url.private_downloads.patch | 614 bytes | koorneef | |
Comments
Comment #1
deadpan CreditAttribution: deadpan commentedthe fileupload example module from http://drupal.org/doxygen/drupal/fileupload_8module-example.html
has the same problem. I got around it by just using the "private" code even if it's supposed to be "public".
Comment #2
TDobes CreditAttribution: TDobes commentedThe reason private downloads are not working for user pictures is that we need a module to define a MODULENAME_file_download function for pictures. This tells file.inc whether the user has the proper permissions to download files. This function used to be in profile.module (profile_file_download), but seems to have been lost in the transition to pictures being handled by user.module.
The attached patch creates a user_file_download function in user.module, using slightly modified code from the 4.4 version of profile.module. With it, avatars do appear properly with a private download method.
Comment #3
Dries CreditAttribution: Dries commentedCommitted to HEAD. Thanks TDobes (again).
Comment #4
(not verified) CreditAttribution: commentedComment #5
Dublin Drupaller CreditAttribution: Dublin Drupaller commentedhave the same problem with 4.5.
i.e. when a user edits account details and clicks Save....the picture/avatar is automatically deleted.
Any1 got any ideas?
J
Comment #6
killes@www.drop.org CreditAttribution: killes@www.drop.org commentedJason, please test with a recent 4.5 cvs checkout.
Comment #7
killes@www.drop.org CreditAttribution: killes@www.drop.org commentedNo response.
Comment #8
(not verified) CreditAttribution: commented