Setting the "Maximum resolution for uploaded images" in /admin/config/media/uploads isn't being respected.
0x0 is set for no restriction and is a special case that isn't being noted in the error messages or descriptions.
This patch (which needs a bit of a cleanup still) makes sure that we're not telling folks that their images will be restricted to 0x0 pixels.
Mike
| Comment | File | Size | Author |
|---|---|---|---|
| #16 | Maximum_Respect_3_2_again_you_stupid_bot.patch | 4.9 KB | jim0203 |
| #11 | Maximum_Respect_3_2.patch | 4.9 KB | jim0203 |
| #7 | Maximum_Respect_3_1.patch | 2.75 KB | jim0203 |
| #4 | Maximum_Respect_3.patch | 2.34 KB | mgifford |
| #2 | Maximum_Respect_2.patch | 2.33 KB | mgifford |
Comments
Comment #2
mgiffordNot sure why this failed the bot test. Re-rolled with fuzz removed.
Comment #4
mgiffordI again applied this patch with no problem and then rebundled it to remove the fuzz.
Comment #5
jim0203 commentedThe patch passes as far as I'm concerned - code is clean and follows standards, and has the stated effect.
I think we can do better than this, however.
Firstly, when the width and height are set at admin/config/media/uploads, there is a nice usability tweak which specifies which of the two numbers entered are width, and which are height. However, when a user goes to upload an image, they are told only that,
Or whatever the file size is set to: the point is, the user isn't told whether the image has to be 100 pixels wide, or high.
Secondly, if only the width or the height is set at admin/config/media/uploads, but not both, then when a user goes to upload an image they are told that,
Surely it would be better to have this say "Images greater than 90 pixels in height will be resized" would be clearer?
Finally, rather than the dimensions being given as 100x90, wouldn't it be more user-friendly to give them as "100px by 90px" or similar?
I'm happy to roll the patch for this once I've had some feedback to let me know whether it's worthwhile or not. In the meantime, mgifford's patch is certainly worth committing IMHO.
Comment #6
mgiffordI do think that 100x90 is reasonable short hand for web folks, but most folks would prefer to know which px is height and which is width. Also in instances where someone is trying to upload a file that is taller or wider than the minimum standards.
My main concern was the error message that was popping up and made no sense. I'd like to get some traction on this and get it into core though so if rolling a new patch with these usability enhancement gets peoples attention & brings it into core I'm good with it.
I think it's worth rolling a different patch with your enhancements though.
Comment #7
jim0203 commentedTry this on for size. Does what I described above, based on your original patch. The wording could probably do with some tightening.
I agree that 100x90 is fine for tech people (although I often forget the order - and in fact I forgot it while I was writing this patch!) but at the moment I'm working on the understanding that Drupal is moving towards being more user-friendly for people with minimal tech skills: i.e., the Wordpress crowd :-P
Comment #8
dman commentedJust checking, is this the problem that this patch is trying to fix?
I just tried out a clean install (todays HEAD, without this patch) and made a content type, enabled upload and image, made a page, attached a jpeg as an attachment and got the message:
The image was resized to fit within the maximum allowed dimensions of 0x0 pixels.That's a WTF.
It doesn't seem to have actually done so anywhere I can see, but is scary UX.
This patch is trying to fix that, right? Yet the default value of '$maximum_dimensions' is defined as '0'.
Either we need to change that API signature to $maximum_dimensions = '0x0'
or the check should be more like
file_validate_image_resolution()?
Related, but not the issue: #516790: File validate image resolution inaccurate in some situations
I'm also getting a bunch of PHP warnings at the same time:
but that is unrelated, and I'm looking for issues to try and solve that elsewhere.
Comment #9
mgiffordI installed patch 3.1 too and didn't get as far as validating if it worked or not. I got distracted by the notice errors that you pointed out and assumed that they were brought in by this patch. It must be a problem with something else in core though......
Version 3 which I published does introduce the checks for $maximum_dimensions != '0x0' and this was brought over to 3.1.
There is a problem with inconsistent spacing in the changes to modules/upload/upload.module it needs to follow the style guide.
I do like the direction of this patch, and yes, totally agree with the WTF tag being added.
Comment #10
jim0203 commented@dman
That is indeed the problem that this patch tries to fix. AFAIK $maximum_dimensions could never have the value 0; it is always WxH where W and H are integers. This is how it is set in the config screen for upload.module.
I'm not quite sure where $minimum_dimensions is set, but it's set to 0 in this example according to my debugger.
I think that both variables should be set as WxH, with 0x0 implying that there is no constraint, if for no other reason than this is how a lof of Drupal expects these things to be set and it's probably the least amount of work to do it this way.
As for all the other error messages, they're generated somewhere in ajax_render() on line 707 of upload.module.
Marked as "needs work"; I think we should aim for a patch that (1) removes all the weird messages that contain 0x0, and (2) sets $maximum_dimensions and $minimum_dimensions consistently. The error messages can be dealt with somewhere else.
Comment #11
jim0203 commentedNew patch. Should remove all weird messages that contain 0x0, set variables correctly (i.e., to 0x0) in the API signature. Tidied up the code so that it conforms to standards - had tabs set wrong in TextMate. Will now look at those error messages.
Am being deliberately bold here with regards to the signature so feel free to disagree.
Comment #12
dman commentedSorry for mixing those PHP notices in here, I just mentioned them as they were appearing at exactly the same time, and symptoms like that are sometimes useful in a bug report :-)
Follow up here : #612396: Notice: Undefined index: process_input in _form_builder_handle_input_element()
RE the patch, I agree that changing the function signature makes more sense than the previous situation. Looks like it does the job. I'll test a bit more...
Comment #13
mgiffordswitching it back so the bot reviews it. Quick code scan it looks much better.
Comment #15
mgiffordOk. Maybe I'm missing something, but I'm pretty sure that this is a bot error.
Failed: Invalid PHP syntax in modules/upload/upload.module.
I don't seen any errors on a fresh install where I applied it.
Comment #16
jim0203 commentedI've had more luck in the past by re-uploading the patch, so here we go:
Comment #17
mgiffordNow they've both passed so seems it was a bot problem. Thanks @Jim0203!
Added a usability tag as I think this is a bug that needs to be noticed and is pretty much RTBC.
Comment #18
drewish commentedupload module has been killed.
Comment #19
mgiffordAhh, so that's why I couldn't find it earlier. Thanks! Setting this to closed, although I'm assuming this will be a contrib module, right?