function emthumb_widget_upload_button_submit in Embedded Media Field 6
Same name and namespace in other branches
- 6.3 contrib/emthumb/emthumb.module \emthumb_widget_upload_button_submit()
- 6.2 contrib/emthumb/emthumb.module \emthumb_widget_upload_button_submit()
1 string reference to 'emthumb_widget_upload_button_submit'
- emthumb_widget_element_process in contrib/
emthumb/ emthumb.module - Process our emthumb element.
File
- contrib/
emthumb/ emthumb.module, line 219 - Allows for custom thumbnail overrides to Embedded Media Field.
Code
function emthumb_widget_upload_button_submit($form, &$form_state) {
$delta = substr($form_state['clicked_button']['#name'], strrpos($form_state['clicked_button']['#name'], '_', -(strlen('_upload') + 1)) + 1, -strlen('_upload'));
$fieldname = substr($form_state['clicked_button']['#name'], strlen('emthumb_'), -strlen("_{$delta}_upload"));
$field = $form['#field_info'][$fieldname];
$upload_op = 'emthumb_' . $fieldname . '_' . $delta . '_upload';
$validators = array(
'emthumb_validate_is_image' => array(),
);
$filename = $source = $fieldname . '_' . $delta . '_file';
if ($file = file_save_upload($filename, $validators, file_create_path($field['widget']['emimport_image_path']), FILE_EXISTS_RENAME)) {
$file = (array) $file;
$file = _emthumb_scale_image($file, $field['widget']['emthumb_max_resolution']);
$form_state['storage']['emthumb'][$upload_op] = $file;
}
else {
form_set_error('', t("There was an error uploading your file."));
}
}