Created
July 9, 2014 04:57
-
-
Save guoxiangke/4980f959625f721cafe2 to your computer and use it in GitHub Desktop.
默认对用户头像 剪切
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//https://www.drupal.org/project/jcrop_form_element | |
/** | |
* Implements hook_form_alter(). | |
*/ | |
function jcrop_fapi_form_alter(&$form, &$form_state, $form_id) { | |
$form['picture']['picture_upload']['#type'] = 'jcrop_image'; | |
$libraries = libraries_load('jcrop', $variant = NULL); | |
libraries_load_files($libraries); | |
array_unshift($form['#submit'], 'jcrop_form_submit'); | |
} | |
/** | |
* Implements hook_views_form_submit(). | |
*/ | |
function jcrop_form_submit($form, &$form_state) { | |
if(isset($form_state['values']['picture_upload']['fid'])) | |
$fid = $form_state['values']['picture_upload']['fid']; | |
// // Load the file via file.fid. | |
$file = file_load($fid); | |
$form_state['values']['picture_upload'] = $file; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment