I'm doing a form programmatically. I need to give an option to upload an image and give an option to resize it ( like cropping option ).
I don't know how to do it, I know that I need to upload the image to a directory and also I suppose that I need to show a relation between the node and the image in the database.
I've created a field called field_img.
So, how can I do it?
This is the form that I've done but I don't know how to give a relation in the database...
form['group_anuncio']['imagen'] = array(
'#title' => t('Image'),
'#type' => 'managed_file',
'#upload_validators' => array('file_validate_extensions' => array('jpeg jpg png gif')),
'#upload_location' => 'public://sites/default/files',
'#progress_indicator' => 'throbber',
'#status' => FILE_STATUS_PERMANENT,
'#progress_message' => 'One moment while we save your file...',
);