Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I'm using FAPI to build a custom form and I use managed_file to upload a picture and save it.
Is it possible to use imagefield crop with the code of form API ?
I have this simple piece of code for my managed_file:
$form['image'] = array(
'#type' => 'managed_file',
'#title' => t('My image'),
);
Thanks.
Comments
Comment #1
8ballsteve CreditAttribution: 8ballsteve commentedAm looking for similar functionality - Would love to know how you resolved this?
Comment #2
citricguy CreditAttribution: citricguy commentedDid anyone accomplish this yet?
Comment #3
nikolaosinlight CreditAttribution: nikolaosinlight commentedYet another person looking for how to do this - does anyone have a solution - module looks great but simply need form API support!
Comment #4
martinpesout CreditAttribution: martinpesout commentedHi, have you resolved this issue? Is it possible to use crop field widget?
Thanks a lot
Comment #5
dhwani CreditAttribution: dhwani commentedHello,
Does anyone have solution ?
I tried :
$form[ 'experience_image1' ] = array(
'#type' => 'managed_file',
'#upload_validators' => array('file_validate_extensions' => array('jpeg jpg png gif')),
'#upload_location' => 'public://picture',
'#progress_indicator' => 'throbber',
'#status' => 1,
'#title' => '',
'#widget' => array('type' => 'imagefield_crop')
);
But crop is not working.
Comment #6
dhwani CreditAttribution: dhwani commentedComment #7
Robytfc CreditAttribution: Robytfc commented+1 I am also looking for a way of doing this. I've tried using the imagefield_crop field type from 2.x-dev in my form alter but nothing displays.
I've also tested using media from the mediafield module and it works as expected when doing this.
Comment #8
gateway69 CreditAttribution: gateway69 as a volunteer commentedDid anyone figure this out?
Comment #9
Robytfc CreditAttribution: Robytfc commented@gateway69 I managed to get this working by using this sandbox module. https://www.drupal.org/sandbox/meadhu/1870050
Comment #10
awelch CreditAttribution: awelch commented@Robytfc - did you manage to get the sandbox module working off the bat? I'm getting some issues using it like it not picking up the crop area in the form fields and saving the cropped image incorrectly.
UPDATE:
I realised it is saving the images cropped properly, but doesn't appear to referencing them properly in the files tab in drupal.