Improve default user picture interface

Dave Reid - September 9, 2008 - 03:23
Project:Drupal
Version:7.x-dev
Component:user.module
Category:feature request
Priority:normal
Assigned:Dave Reid
Status:needs work
Issue tags:Usability, user pictures
Description

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.

#1

Dave Reid - September 9, 2008 - 06:27
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 KBIgnoredNoneNone

#2

Dave Reid - September 9, 2008 - 07:52

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 KBIgnoredNoneNone

#3

maartenvg - September 9, 2008 - 09:35

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 KBIgnoredNoneNone

#4

Dave Reid - September 9, 2008 - 14:04

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 KBIgnoredNoneNone

#5

webchick - September 10, 2008 - 05:03

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

Dave Reid - September 10, 2008 - 05:03
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

Dave Reid - September 10, 2008 - 10:24
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: Enabling user pictures is confusing
#141541: Files directory check doesn't disable uploads if check fails, in admin/user/settings

#8

maartenvg - September 16, 2008 - 07:05

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

#9

Dave Reid - September 16, 2008 - 12:57

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

#10

Dave Reid - October 11, 2008 - 02:28
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

Dave Reid - January 6, 2009 - 21:47

#12

Dave Reid - January 17, 2009 - 06:33
Issue tags:+user pictures

#13

Dave Reid - January 17, 2009 - 06:42
Issue tags:+Usability

#14

quicksketch - February 9, 2009 - 04:34

Subscribe

#15

skiquel - May 5, 2009 - 12:17

subscribe.

 
 

Drupal is a registered trademark of Dries Buytaert.