Updated: Comment #15
Problem/Motivation
If a site has the Default picture for user accounts set to a hard path like /sites/default/files/image.jpg
, modules like Views can't properly detect the default image, and will display no image at all if a user doesn't have an image stored. Additionally, workarounds that exist bypass image styles, so the default image won't be properly resized.
Proposed resolution
Improve the description of the 'Default picture' textfield on the user account settings page (admin/config/people/accounts
) and mention the use of the public://
stream wrapper..
Remaining tasks
Review the latest patch.
User interface changes
Update the description of the user account settings 'Default picture' textfield to make it obvious that the path should include the public file stream wrapper (public://
) so image styles and views work properly with the default image.
API changes
None.
Related Issues
None.
Original report by lsolesen
This module works great when the users have uploaded a picture, but the default picture is not resized.
Comment | File | Size | Author |
---|---|---|---|
#15 | 1413824-15-public-file-path-default-picture.patch | 896 bytes | geerlingguy |
Comments
Comment #1
jordi_bcktt CreditAttribution: jordi_bcktt commentedI have the same problem
Comment #2
lsolesen CreditAttribution: lsolesen commentedSeems that the default user pictures is hardcoded and not uploaded through the interface. We should probably file a feature request for Drupal core for this one?
Comment #3
bkonetzny CreditAttribution: bkonetzny commentedThe problem lies within the imagecache_profiles_preprocess_user_picture(), where a check with file_valid_uri($filepath) is done. Setting a default user picture like the docs mention (e.g. a path like "sites/all/themes/mytheme/default.png") fails in file_valid_uri(), as barepaths are not allowed in this function. The check needs to be there, as theme_image_style doesn't work with files outside the files directory. See related #1371742: Default image not being resized.
Comment #4
NathanM CreditAttribution: NathanM commentedAlso having this problem. Strangely, in things like Advanced forum and Author Pane, nothing will show if the default user picture is enabled, but most other situations seem to work fine.
Comment #5
davidcsonka CreditAttribution: davidcsonka commentedNathanM, it seems like there is currently a difference in how Adv Forum and Author Pane retrieve the default user pic.
See here: http://drupal.org/node/1451498
Comment #6
NathanM CreditAttribution: NathanM commentedSorry, that is perhaps a separate issue, but I'm also still having issues with ImageCache Profiles not being able to resize the default picture. I will check out that thread for the other issue. Thank you.
Comment #7
apmsooner CreditAttribution: apmsooner commentedThat link in #5 solved it for me. The solution:
It seems that the best way to fill in the Default picture field is to use a uri schema for the public files directory public:// or private://.
Ex: public://pictures/default.jpg instead of sites/default/files/pictures/default.jpg
When i changed my path to this format, my default picture is scaled appropriately.
Comment #8
lsolesen CreditAttribution: lsolesen commentedThanks, that solved my problem also. Maybe the best way is to create a patch so this is explained in the field description on admin/config/people/accounts --> so it is a core issue. Anyone knows how to move an issue to another project?
Comment #9
apmsooner CreditAttribution: apmsooner commentedMoving this issue to drupal core as it affects modules such as imagecache profiles from properly scaling default picture.
Comment #10
NathanM CreditAttribution: NathanM commentedThanks apmsooner
Comment #11
FiNeX CreditAttribution: FiNeX commentedWhy not simply add a better description on the configuration page in order to explain how to correctly set the path?
Comment #12
geerlingguy CreditAttribution: geerlingguy commentedComment #13
geerlingguy CreditAttribution: geerlingguy commentedI've added an issue summary with the relevant bits. If we could get a good description text together, I'll roll a patch for this.
Comment #14
apmsooner CreditAttribution: apmsooner commentedMaybe something like this?
Note, for more clarity, possibly link "Public file system path" to config page: /admin/config/media/file-system
Comment #15
geerlingguy CreditAttribution: geerlingguy commentedPatch for review, with slightly different text.
Comment #15.0
geerlingguy CreditAttribution: geerlingguy commentedAdded an issue summary.
Comment #15.1
geerlingguy CreditAttribution: geerlingguy commentedUpdated summary.