I have a Flag setup for an image content type which allows users to Flag an image that they want to be their avatar/user picture. I also have a View which displays this flagged image.

When a user clicks this Flag I would like to be able to trigger a crop (where the user is able to select the cropping area manually) so that a copy of the image can be made and referenced in a separate avatar gallery, without effecting the original image which will stay in it's gallery uncropped. There are several cropping solutions for Drupal 7 however is there a way that cropping can be triggered dynamically as in my example, perhaps via Rules or another way?

  • I can imagine it happening via rules and with some helper modules but it is a pretty big task. We can't really design it for you, that's not how this site works.
    – Mołot
    Apr 23, 2014 at 13:15
  • You do not need to copy a cropped image to build an avatar gallery. Instead, you can configure an Image Style to crop your image. Then when displaying the images in your gallery, you display them using that Image Style. Apr 23, 2014 at 13:34
  • 1
    @PierreBuyle if each user is supposed to select his own crop, using image styles is not feasible for this task.
    – Mołot
    Apr 23, 2014 at 14:15
  • @Molot, I suggest you update the question then. In the original version, it is not clear you want the user to be able to select the crop area. Apr 23, 2014 at 17:03
  • @PierreBuyle Original question is not by me. I only presented my understanding of it. Also note that there already is one vote to close on it. If you think it's unclear, you can vote so. Actually, if we both think it's clear, but understand it differently, then we have a proof some clarifications are needed.
    – Mołot
    Apr 24, 2014 at 7:43

1 Answer 1


A module that you want to start looking at is Imagefield Crop. Details from project page:

When the user uploads an image it is presented inside a cropping area. A cropping box is shown inside, and the user can resize and move it. Upon clicking "preview" or "submit", the image is cropped and the result is saved instead of the original image.

Features - Seamless, intuitive cropping, almost like using a desktop photo editing app - All major browsers supported - Dynamic preview - you see how your crop will look like, in real time! - Original image is saved for recropping. - No matter what resolution the cropping area is, the original image is used for cropping (for highest quality) - The sizes of the cropping area, cropping box and resulting image can be controlled by the administrator

The problem with using this module however is that it only works with the imagefield module and the user picture.

If you already have a bunch of users that uploaded avatars using Drupal's core functionality then it would be best to rip the ImageField Crop module apart and see how it can be integrated into Drupal's user avatars.

If you have yet to have any users upload avatars then you can follow these steps....

  1. Create a user field called "Pic" and use the "Image with cropping" widget on it.
  2. When the user flags the image, you can redirect to the user edit page while passing the fid of the flagged image.
  3. After that you can use hook_form_alter to chuck in the fid, uri and fileurl from the passed fid as the '#default_value' of the newly created "Pic" field from step 1.

The annoying thing about this solution is that you will have to modify user-picture.tpl.php to use your custom created field over the default avatar picture.

  • How could this module be used for "dynamic" cropping though? There are plenty of cropping modules available for Drupal, the cropping is not the difficult part, it is how to trigger cropping dynamically say via a link or flag.
    – FrontEnd
    Apr 25, 2014 at 0:40
  • I may have misunderstood. Do you want the user to have the ability to crop the image on the same page where they flag it? Apr 25, 2014 at 1:16
  • It could be on the same page, it does not really matter. I suggested using Rules because once the image is flagged as an avatar picture it would need to be referenced by rules into the correct gallery
    – FrontEnd
    Apr 25, 2014 at 1:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.