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.

None.

Original report by lsolesen

This module works great when the users have uploaded a picture, but the default picture is not resized.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jordi_bcktt’s picture

Issue tags: +user picture, +default picture

I have the same problem

lsolesen’s picture

Seems 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?

bkonetzny’s picture

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

NathanM’s picture

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

davidcsonka’s picture

NathanM, 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

NathanM’s picture

Sorry, 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.

apmsooner’s picture

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

lsolesen’s picture

Thanks, 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?

apmsooner’s picture

Title: Default picture not resized » Field description should explain url schema for default user pictures to be example: public://pictures/default.jpg
Project: ImageCache Profiles » Drupal core
Version: 7.x-1.0 » 7.12
Component: Code » user.module

Moving this issue to drupal core as it affects modules such as imagecache profiles from properly scaling default picture.

NathanM’s picture

Thanks apmsooner

FiNeX’s picture

Why not simply add a better description on the configuration page in order to explain how to correctly set the path?

geerlingguy’s picture

Version: 7.12 » 7.x-dev
geerlingguy’s picture

I'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.

apmsooner’s picture

Maybe something like this?

Path should be prefixed with: public:// to locate file relative to the <a href="/admin/config/media/file-system">Public file system path</a>.
Example: public://pictures/userdefault.jpg

Note, for more clarity, possibly link "Public file system path" to config page: /admin/config/media/file-system

geerlingguy’s picture

Status: Active » Needs review
FileSize
896 bytes

Patch for review, with slightly different text.

geerlingguy’s picture

Issue summary: View changes

Added an issue summary.

geerlingguy’s picture

Issue summary: View changes

Updated summary.