The /admin/user/settings page has an option for 'Maximum Picture Dimensions' and helpfully states that the measurement is in pixels.

Say a user requires a maximum image size of 100 x 100 pixels, what gets put in the box?

100
100x100
100*100
100,100

Not knowing what to use, the first thing a user might try is to guess at some reasonable input and have the system provide helpful feedback if the input is not vaild.

'foo' Is not a sensible dimension, yet when used in that field the module accepts it as perfectly valid.

CommentFileSizeAuthor
#4 validate_max_dimensions.patch1.55 KBksenzee
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ricabrantes’s picture

Version: 5.1 » 7.x-dev

Confirmed.. moving to new version..

LAsan’s picture

Verified in 7.x-dev.

ksenzee’s picture

Assigned: Unassigned » ksenzee

I'll take a stab at this...

ksenzee’s picture

Status: Active » Needs review
FileSize
1.55 KB

This patch adds a validator and some explanatory text for the maximum picture dimensions field. If you enter 'foo' or '80', it throws an error. '100x125' is accepted. A better approach might be to have two separate textfields, one for width and one for height, but this patch at least solves the immediate problem.

lilou’s picture

Title: Input checking missing and input format ambiguity » Validate max dimensions

You patch look good, but i think it need a .test for user_picture_dimensions

lilou’s picture

Title: Validate max dimensions » Maximum dimensions for pictures more explicite
dmitrig01’s picture

Title: Maximum dimensions for pictures more explicite » Validate max dimensions
Status: Needs review » Reviewed & tested by the community

Works for me, and looks good. Much needed. Not sure if it needs a test because that's basically testing php's explode().

lilou’s picture

Title: Validate max dimensions » Maximum dimensions for pictures more explicite

Cross-post for title ;-)

Dries’s picture

Status: Reviewed & tested by the community » Needs work

1. It could use a test.

2.

+  if(empty($dimensions)) {
+    return;
+  }

It is not clear what this check is for. Wouldn't an empty dimension be a problem? The form description does not mention that it is a special case.

3. There are some minor code style glitches.

drewish’s picture

i kind of think it'd be worth the trouble to add a dimensions form element. we could use it several places in core and i can think of a few contrib modules that could use it. would that be worth pursuing?

ksenzee’s picture

Title: Maximum dimensions for pictures more explicite » Validate maximum picture dimensions

I agree it could use a test. I'll come up with one and address the other issues in #9. However, I also like the idea of adding a dimensions form element to core, and since I just figured out hook_elements 5 minutes ago (ahem) I could maybe whip one up. It would definitely be neater than the current patch. If I don't hear anything to the contrary I'll go ahead with that approach.

drewish’s picture

ksenzee, please do and post a link so i can follow up on that issue. i've been thinking more and more that it'd be handy to have.

Dave Reid’s picture

Issue tags: +Needs tests, +user pictures

Adding tags

mgifford’s picture

This looks like it's related to this issue:
#590616: 0x0 Image Filesize Shouldn't Come With 0x0 Warnings

MichaelCole’s picture

Writing a test today.

MichaelCole’s picture

Status: Needs work » Closed (won't fix)

Bug no longer relevant.

New UI has seperate fields for x and y.

New UI is at: http://www.d7c.dev/user/1/edit?destination=admin/people#overlay=admin/co...

Verify and close.