If a crop style is required for an image upload field, a red error message is presented to the user as soon as they attach the image, but before they've had a chance to apply the crop yet.

imagename.jpg must have a cropping selection for the thumbnail image style.

While I see no problem with prompting the user to add a crop to the image, the error displayed above could honestly be a bit frightening to your average end user (I'm talking about the people I'm building the site for here, not myself and other developers) as it has a large red X and red border to emphasise that it's an error. In actual fact, it's not really an error so much as a required future action.

My suggestion would be to use a less confrontational message style, and change the message to something along the lines of:

Please click the crop button to set the display area for filename.jpg

Comments

tessa bakker’s picture

Hi ohnojono,

Please click the crop button to set the display area for filename.jpg

Is not direct enough for a required style and a display area is too vague.

Maybe something like:

%filename requires a cropping selection for the @style image style

matthijs’s picture

Assigned: Unassigned » matthijs
Status: Needs review » Postponed (maintainer needs more info)

Normally this message shouldn't be displayed after uploading a file. Could you give me some steps/info (used widget, applied settings...) to reproduce?

Thanks!

matkeane’s picture

I'm seeing the same message, with the added annoyance that the error message seems to prevent the 'add' button displaying on a field with multiple images. The node must be saved before another image can be added.

This is on a site using a combination of Media 7.x-2.0-alpha4+38-dev and Manual Crop 7.x-1.5.
Libraries: imagesLoaded v2.1.0 & imgAreaSelect v0.9.10.

The field is an image field using the Media Browser widget and set to allow unlimited values.

In the Manual Crop settings for the field, 1 style is selected in the Styles list, and the same 1 style is selected as a Required Cropping.

After adding an image using the 'Attach media' button, and selecting an image from the Media library, the Media popup window closes and a 'please wait' message appears for a fraction of a second, before the "my_image.jpg must have a cropping selection for the Main Image image style" warning appears above the image field. I can click on the 'crop' button to apply a crop but afterwards the warning is still displayed above the image field, and the 'Attach media' button is now hidden. To add another image, the node must be saved and re-edited.

In the past, I seem to remember the crop window opening automatically after an upload was complete, which avoided the warning, but I can't seem to find this option now.

I can remove an image from the list, but the crop warning persists, even after the image is removed from the field.

I'm happy to supply more info if that helps.

nitebreed’s picture

I'm having the same issue

Anonymous’s picture

We had issue with this because cropped images with maximized area did not match the original image so we had to implement a solution for this and I came up with this. I'm not sure if this is the correct story but maybe it will help someone:

--- a/manualcrop.module
+++ b/manualcrop.module
@@ -433,6 +433,20 @@
             $element_key = implode('][', $image['element_parents']) . '][manualcrop_selections][' . $style_name;
           }
 
+          // Make sure the dimensions are available.
+          if (!empty($image['uri'])) {
+            $image_info = image_get_info($image['uri']);
+            if ($image_info) {
+              $image['width'] = $image_info['width'];
+              $image['height'] = $image_info['height'];
+            }
+          }
+
+          // If no cropping was made, use the full width and height if the image.
+          if (empty($crop) && !empty($image['width']) && !empty($image['height'])) {
+            $crop = '0|0|' . $image['width'] . '|' . $image['height'];
+          }
+
           if (!empty($crop)) {
             // Validate the crop selection format.
             if (preg_match('/^([0-9]+\|){3}[0-9]+$/', $crop)) {
stevendeleus’s picture

My suggestion is to replace the required cropping style with:

<?php
          elseif (in_array($style_name, $image['required_styles'], TRUE)) {
            // Uncropped required style.
            if(!isset($form_state['triggering_element']['#processed']) || $form_state['triggering_element']['#processed']) {
              $error_set = TRUE;
              form_set_error($element_key, t('%filename must have a cropping selection for the @style image style.', array(
                '@style' => $clean_style_name,
                '%filename' => $image['filename']
              )));
            } else {
              drupal_set_message(t('%filename must have a cropping selection for the @style image style.', array(
                '@style' => $clean_style_name,
                '%filename' => $image['filename']
              )), 'warning', FALSE);
            }
          }
?>

This will output a warning if the form processing is not over and will still show the error if the form is submitted at the moment we want validation.

dqd’s picture

Title: Overly aggressive error displayed on image attach » Misleading message with status "Error" displayed on simple image attach.
Issue tags: -error message, -User interface

...

To #3: But this can very certainly also be a mix of Media module issues, but not Manual Crop only.

In the past, I seem to remember the crop window opening automatically after an upload was complete, which avoided the warning, but I can't seem to find this option now.

Maybe this was before you have used Media module? I am just asking to follow the maintainers request at #2 to report clearly so that he can reproduce this issue.

I will link #2728645: Compatibility with Media 7.x-2.0-beta2 and duplicate labels after cropping image to this issue to check for possible overlaps ...

Info: I removed the random issue tags. "User interface" is the chosen component of this issue already. Please follow the advices on the issue tag field: Before adding tags read the issue tag guidelines. Do NOT use tags for adding random keywords or duplicating any other fields.

dqd’s picture

hiramanpatil’s picture

is there any patch to resolve this issue? It appears every time when I upgrade 'manualcrop' module.

Thanks,