First of all, I am *so* happy to see the profile image as an actual field, so YAY to everyone who helped get that done :)
This issue is so we can actually use it :)
Problem/Motivation
Today, I decided to test the patch that updated user module to Twig. "First things first", I thought, "...let's make some users!" I navigated to the user list, and edited a user. "Okay, let's upload a picture." I browse to my avatars directory, choose the same avatar photo I add to every drupal site I've ever had an account on, and upload.
I get this message (in green):
The image was resized to fit within the maximum allowed dimensions of 85x85 pixels.
YAY! :)
Then, I get this error (in read, beneath the green message):
The specified file jenmainstage_sm.png could not be uploaded. The file is 112.08 KB exceeding the maximum file size of 30 KB.
BOO.
I read the error message. Think: "30 KB? really?". Think some more: "Surely, I changed these settings when I was testing something else, that can't be right." I return to the settings page seeking the "Reset to defaults" button, which of course, is not there. So I reinstall Drupal. Try again. Same problem. :/
On further examination, it turns out that the upload dimensions are set to 85x85px, but even the thumbnail image that is displayed after the image is uploaded (in the form, as well as on the user page) is 100x100. That means we're going to be scaling up profile images since we don't have an image style in core that's this tiny.
Proposed resolution
- We should allow a large profile image to be uploaded. Since we're resizing the image on disk anyway, the file size will decrease as well. I'm not sure we need a restriction here at all, but we certainly don't need one that's so restrictive that even a fairly savvy web user like myself doesn't have a profile photo this tiny on hand.
- We should increase the maximum image dimensions. If there's no way to display these images on the site without up-scaling them, then we are setting the size too small. Large images will still look alright when sized down, but images that are sized up will not always look nice.
- If we really want the images to be 85x85, we should provide an image style that matches the intended size for profile photos. Sizing them up to 100x100 when the files are 85x85 was probably not intended.
- If we really want the images to be 85x85, we should set this new image style as the default formatter for the profile image field. This will avoid up-scaling.
- We should also stop calling dimensions "resolution".
Remaining tasks
- allow a large profile image to be uploaded
- increase the maximum image dimensions
- provide an image style for user photo
- set the image field to use this new image style
- #1215784: Terminology update: don't say "Resolution" when we mean "Dimensions"
User interface changes
none
API changes
none
Related Issues
#1215784: Terminology update: don't say "Resolution" when we mean "Dimensions"
Comment | File | Size | Author |
---|---|---|---|
#32 | drupal_user_picture_1930934-27.patch | 714 bytes | Berdir |
#28 | drupal_user_picture_1930934-27.patch | 714 bytes | andrewmacpherson |
#24 | drupal_user_picture_1930934-24.patch | 680 bytes | floretan |
#19 | drupal_user_picture_1930934_19.patch | 2.66 KB | mkadin |
#18 | drupal_user_picture_1930934_18.patch | 2.66 KB | mkadin |
Comments
Comment #1
mkadin CreditAttribution: mkadin commentedAll of this sounds reasonable.
1) I don't see why we need to change the size of the image on upload. What is the purpose in this? Even if we set it to 100 x 100 it may not match the image style if a site builder decides to override it. My vote would be for no upload resizing. Maybe a very large maximum so someone malicious doesn't try to upload some kind of crazy large image that will crash things.
2) 30 Kb is definitely too small, maybe 1 MB is better?
3) Assuming #1 is acceptable, I think we can stick to the thumbnail image style as the default.
I'm down to patch this once we have agreement.
Comment #2
BerdirThese settings likely date back multiple core version, certainly way before there were image styles in core.
Back then, these limitations made a lot of sense. Today, they no longer do and we can probably simply remove them. The image size is still limited by whatever the maximum is your server allows.
And if you're building sites with user profiles there is a high chance that you want your profile images to be in a decent quality.
To remove them, we should probably make sure that we always use an image style for the default places where it's displayed.
Comment #3
mkadin CreditAttribution: mkadin commentedBoth the comment and node modules actually provide the user pictures by rendering the 'compact' (used to be called 'teaser') display of the user entity before passing to the template, so I think we're safely displaying the picture using an image style everywhere it gets displayed.
Attached patch removes the restrictions and corrects a little typo a few lines down. Tested it, works fine.
I think I'll open up a separate issue about how 'user pictures' can actually contain any number of different fields, since checking the 'show user pictures with posts' box in your theme settings actually displays a user entity's compact view mode. Seems like we need a name change.
Comment #4
BerdirChecked the user display fields and it's also using the 100 x 100 px thumbnail there. The only weird thing there is that it links to content, which in case of a user profile/page is the same page. Not sure if we want to clean that up here as well or not.
Also not sure about the upgrade path but I assume we keep the existing settings there and don't try to be too intelligent.
Comment #5
mkadin CreditAttribution: mkadin commentedI think it could be argued that 'link to content' should be the standard case for the user entity, so perhaps we should leave that out for now.
This patch replaces the upgrade path defaults with the new default settings as well.
Comment #6
mkadin CreditAttribution: mkadin commentedDiscussed this with berdir in IRC and decided that the default link to 'content' is not right, so this patch removes that as well.
Comment #8
Berdir#6: drupal_user_picture_1930934_6.patch queued for re-testing.
Comment #9
sunThis makes sense to me.
But I think we want to keep a maximum allowed filesize; this can and will be abused by users otherwise — something along the lines of the suggested 1 MB sounds sensible, although that's pretty much already... We should orient ourselves at typical image file sizes of today's cameras.
We definitely want to do this, but it's definitely also not "major". :) (As a general rule of thumb, anything that is tagged as Novice cannot really be major ;))
Comment #10
mkadin CreditAttribution: mkadin commentedSounds reasonable...a full res iphone or 8 megapixel android phone picture can sometimes be greater than 1 MB. I'd suggest 2MB, which I think is the standard upload limit for stock php anyway. A high res photo from a DSLR might exceed this, but for a profile field that defaults to 100 x 100, I think its acceptable to force that user to re-size the file.
This can of course be overridden by the site builder to whatever they desire.
Anyone else have opinions?
Comment #11
BerdirLooks good to me.
Comment #12
BerdirOk, I think those are sane defaults, it takes care of both new installations and upgrade (uses the new default value if nothing has been explicitly configured and the configured values otherwise).
Looks good to go to me.
Comment #13
xjm#10: drupal_user_picture_1930934_10.patch queued for re-testing.
Comment #14
webchickThis looks good overall, but one quick thing. We should take the lesser of 2MB vs. php.ini's "upload_max_filesize" variable. It's possible for this to be set to 1MB on a server and then Drupal barfs in interesting ways. (It's unlikely it would be set to < 30K, so this wasn't really required before.)
Comment #15
sunGood point.
Let's do that literally though; i.e.:
Comment #16
mkadin CreditAttribution: mkadin commentedHows this
Comment #17
xjmShouldn't we be taking the system configuration into account here as well?
Minor: Looks like this comment is wrapping a bit too late. It should wrap as close to 80 chars total (including the spaces at the beginning) without going over.
Comment #18
mkadin CreditAttribution: mkadin commentedDuplicate the same chunk of code?
Comment #19
mkadin CreditAttribution: mkadin commentedwtf, netbeans decided to put the little 80 character line where it felt like it
Comment #19.0
mkadin CreditAttribution: mkadin commentedbullets
Comment #20
socketwench CreditAttribution: socketwench commentedNovice issue cleanup.
Comment #21
arkiii CreditAttribution: arkiii commentedI'm at the sprint in Austin taking a look at it...
Comment #22
arkiii CreditAttribution: arkiii commentedThe patch in #19 did not apply cleanly.
Comment #23
Jeff Burnz CreditAttribution: Jeff Burnz commented+1 for this, the 30kb limit is really odd in todays web, in fact its just weird for most users to hit this very, very low limit.
I think this is a major WTF to be frank, absolutely no other web service out there expects average users to be restricted to 30kb.
Comment #24
floretan CreditAttribution: floretan at Wunder commentedNow that this configuration is a simple yaml file in the installation profile the patch becomes quite trivial.
Note that we are losing the arbitrary limitation of uploaded images to 2mb, although that is a common default php configuration so in most case there is no change for the final limitation.
Comment #28
andrewmacpherson CreditAttribution: andrewmacpherson as a volunteer and at Annertech commentedPatch from #24 no longer applies, needs a simple re-roll.
Comment #31
vitaliych CreditAttribution: vitaliych commentedDid any body tried just configure user picture field in acount settings as i did? No issue appeared after configuration. Yes i've got it at first before configuring the field settings but after that everything working fine. so why we need that patch ? Am i missing somesting?
Comment #32
BerdirSure, you can change it. This is just about changing the default so you don't have to do that on every site you use this feature on.
Just re-uploading the patch, still applies but wasn't tested before.
Comment #33
tstoecklerThis is consistent with the image field on articles, so if we can get away without a max filesize there, I think we are good here as well.
Comment #35
catchYes the limit isn't relevant any more with image derivatives, so agreed on just removing it.