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

User interface changes

none

API changes

none

#1215784: Terminology update: don't say "Resolution" when we mean "Dimensions"

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mkadin’s picture

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

Berdir’s picture

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

mkadin’s picture

Status: Active » Needs review
FileSize
924 bytes

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

Berdir’s picture

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

mkadin’s picture

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

mkadin’s picture

Discussed this with berdir in IRC and decided that the default link to 'content' is not right, so this patch removes that as well.

Status: Needs review » Needs work
Issue tags: -Novice

The last submitted patch, drupal_user_picture_1930934_6.patch, failed testing.

Berdir’s picture

Status: Needs work » Needs review
Issue tags: +Novice

#6: drupal_user_picture_1930934_6.patch queued for re-testing.

sun’s picture

Priority: Major » Normal
Issue tags: +Usability

This 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 ;))

mkadin’s picture

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

Berdir’s picture

Looks good to me.

Berdir’s picture

Status: Needs review » Reviewed & tested by the community

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

xjm’s picture

webchick’s picture

Status: Reviewed & tested by the community » Needs work

This 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.)

sun’s picture

Good point.

Let's do that literally though; i.e.:

$limit = min(2048000, file_upload_max_size());
$limit = ($limit > 1024 ? format_size($limit) : 0);
// or perhaps rather this?
$limit = $limit / DRUPAL_KILOBYTE . ' KB';

// ...
  'max_filesize' => $limit,
mkadin’s picture

Status: Needs work » Needs review
FileSize
2.26 KB
1.12 KB

Hows this

xjm’s picture

+++ b/core/modules/user/user.installundefined
@@ -332,10 +332,10 @@ function user_install_picture_field() {
-      'max_filesize' => '30 KB',
+      'max_filesize' => '2 MB',

Shouldn't we be taking the system configuration into account here as well?

+++ b/core/modules/user/user.installundefined
@@ -718,6 +718,10 @@ function user_update_8011() {
+  // Use 2 MB as a default user picture file size, without exceeding the configured PHP
+  // limit.

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.

mkadin’s picture

Duplicate the same chunk of code?

mkadin’s picture

wtf, netbeans decided to put the little 80 character line where it felt like it

mkadin’s picture

Issue summary: View changes

bullets

socketwench’s picture

Issue tags: -Novice

Novice issue cleanup.

arkiii’s picture

I'm at the sprint in Austin taking a look at it...

arkiii’s picture

Status: Needs review » Needs work

The patch in #19 did not apply cleanly.

Jeff Burnz’s picture

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

floretan’s picture

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

Status: Needs review » Needs work

The last submitted patch, 24: drupal_user_picture_1930934-24.patch, failed testing.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

The last submitted patch, 24: drupal_user_picture_1930934-24.patch, failed testing.

andrewmacpherson’s picture

Patch from #24 no longer applies, needs a simple re-roll.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

vitaliych’s picture

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

Berdir’s picture

Status: Needs work » Needs review
FileSize
714 bytes

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

tstoeckler’s picture

Status: Needs review » Reviewed & tested by the community

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

  • catch committed 85ee07c on 8.4.x
    Issue #1930934 by mkadin, Berdir, floretan, andrewmacpherson: Set...
catch’s picture

Version: 8.3.x-dev » 8.4.x-dev
Status: Reviewed & tested by the community » Fixed

Yes the limit isn't relevant any more with image derivatives, so agreed on just removing it.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.