Download & Extend

Improve default user picture interface

Project:Drupal core
Version:8.x-dev
Component:user.module
Category:bug report
Priority:normal
Assigned:Dave Reid
Status:needs work
Issue tags:Configuration Management, Usability, user pictures

Issue Summary

If you specify a default user picture (under admin/user/settings) that is larger than the maximum picture dimensions, the dimensions are not enforced for that image. Why can't the default user image be an upload field and work just like a user uploading their own user picture? This would also eliminate some confusion about what exactly should be specified for the path of the default user image: Should I specify a relative path? Relative to what? How do I get the default image there? Should I specify an absolute url? I think this would be +1 for usability.

Comments

#1

Assigned to:Anonymous» Dave Reid
Status:active» needs review

Initial patch ready for review. Will need to re-roll if #142995: Add hook_file and make files into a 1st class Drupal object makes it in before this.

AttachmentSizeStatusTest resultOperations
305802.default.picture.patch3.94 KBIgnored: Check issue status.NoneNone

#2

Forgot to add a form encoding type so the file would actually upload. Confirmed patch uploads, resizes and deletes default picture successfully.

AttachmentSizeStatusTest resultOperations
305802.default.picture.patch4 KBIgnored: Check issue status.NoneNone

#3

I've tested this patch, and came across an error. On a fresh install (or when the user_pictures hasn't been enabled before) when there isn't a 'pictures' directory yet, this patch will upload the default picture before the goal directory has been created. Currently the directory is created after the entire form has been processed and is shown to the user again, while the uploaded file is moved to the goal directory during form validation.

I've attached a patch that fixes this, by creating the folder during the validation process. And +1 for this feature!

AttachmentSizeStatusTest resultOperations
305802.default.picture.patch4.77 KBIgnored: Check issue status.NoneNone

#4

Thanks for that fix maartenvg! I modified it a little bit to use $form_state['values']['user_picture_path'] instead of variable_get since if the user is changing the picture path, that variable hasn't been saved yet. This also cleans up the 'picture_delete' and 'picture_upload' variables that unnecessarily get saved into $user->data from the user edit form.

AttachmentSizeStatusTest resultOperations
305802.default.picture.patch5.31 KBIgnored: Check issue status.NoneNone

#5

Wow. This totally qualifies as one of those "duh" things that we completely overlook because we're all so used to Drupal working this way. Big +1 to seeing this fixed.

However, because this has gone unnoticed for 100s of years, it leads me to believe that this is a relatively obscure setting in Drupal that not many people use. And you know what that means? It means...... we need a test for it, because we're not likely to ever catch it if it breaks. ;)

Also, user_validate_default_picture needs some PHPDoc to satisfy my inner control freak. ;)

#6

Status:needs review» needs work

After discussion with webchick, need to:
- Add default user picture test to user.test
- Document the user_validate_default_picture function

And there's webchick's updated before mine...

#7

Title:Handle default user picture as an upload and enforce maximum picture dimensions» Improve default user picture interface and require image toolkit

Broadening issue a little to incorporate some fixes found in:
#131573: Validate maximum picture dimensions
#27234: Maximum picture size help text in profile no longer needed
#222036: Usability: User picture system is confusing
#141541: Files directory check doesn't disable uploads if check fails, in admin/user/settings

#8

David, are you working on this or is it fine for me to start incorporating the other issues?

#9

I've actually got most of the work done I just need to get some tests written today to wrap this up!

#10

Title:Improve default user picture interface and require image toolkit» Improve default user picture interface

Will split out requiring image toolkit for user pictures to save a kitten and help me focus on this patch.

#11

#12

Issue tags:+user pictures

#13

Issue tags:+Usability

#14

Subscribe

#15

subscribe.

#16

Version:7.x-dev» 8.x-dev

Features go into Drupal 8 now

#17

Crud, and subscribe.

#18

+1 for this as well as making the setting more portable, it doesn't move well between sites using strongarm/features because of the xxx bit in the value (eg sites/xxx/pictures/some-default.png)

#19

Category:feature request» bug report

Using D7 and default picture does not pass and get resized. Looks like this didn't get fixed for D7?

I would say this is actually a bug since it is all about core now since there is no more imagecache for D7. I would also argue that this is a major instead of normal after all this time but I won't upgrade it and leave that to someone else to agree first.

#20

+1 for fixing this and +1 for back-porting to D7 (D6 would be nice, but I won't hold my breath).

#21

I actually think I was talking about something completely different than everyone else. In my case D7 doesn't pass the default image through the image styles if you set the path something like sites/files/pictures/default.png because it makes the file private. You have to set the path to public://pictures/default.png (relative to the path you set for public:// that is.)

That's what I was talking about in my post and didn't really notice everyone else was referencing some other problem. Sorry.

#22

It seems to me this issue's summary talks about two things:

1. Having a better interface, as also suggested by the title (an upload button for example). That would be a feature request.

2. The default user image not being resized. That would be a bug report which seems to be related to these other two issues:
#799178: User default picture path incorrect when run through image styles
#1371742: Default image not being resized

nobody click here