I've done a custom module to generate some forms. There is a image field present. I would like to add cropping functionality in image field.

I've seen that is very interesting the Imagefield Crop module. I would like to use it in my code.

So, my question is: Is there any way to add this module functionality into my image field?

Edit 1:

This is my code:

$form['imagen'] = array(
        '#title' => t('Image'),
        '#type' => 'managed_file',
        '#upload_validators' => array('file_validate_extensions' => array('jpeg jpg png gif')),
        '#upload_location' => 'public://',
        '#progress_indicator' => 'throbber',
        '#status' => FILE_STATUS_PERMANENT,
        '#progress_message' => 'One moment while we save your file...',

It is necessary for our company to generate the forms in a custom module, because we need to process data in a special way, that with drupal content type is not possible.

So, I feel totally lost. It is posible to do something like a reference or something similar to use image_crop??

Thank you in advanced.

  • Of course, it's PHP - copy and change the relevant portions of code into your module. Do you have a specific question?
    – Clive
    Oct 1, 2014 at 10:30
  • you can also use that function by calling that function. Read more about hook implementation.
    Oct 1, 2014 at 10:40
  • I've edited my question, I hope you can help me
    – more770
    Oct 5, 2014 at 10:33

1 Answer 1


If any module is providing its API, than you can use its api.Image Field Crop is not providing any API so you can call any method from that module directly. Don't forgot to add contributed module name as a dependency in your custom module info file.

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.