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

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

deadpan’s picture

the 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".

TDobes’s picture

Assigned: Unassigned » TDobes
FileSize
1.53 KB

The 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.

Dries’s picture

Committed to HEAD. Thanks TDobes (again).

Anonymous’s picture

Dublin Drupaller’s picture

have 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

killes@www.drop.org’s picture

Jason, please test with a recent 4.5 cvs checkout.

killes@www.drop.org’s picture

No response.

Anonymous’s picture