We need to alter the UI of image_miw widget and add the checkbox to select IMCE under the manage fields section of Content Type
/**
* Implements hook_form_FORM_ID_alter().
*/
function custom_form_field_ui_field_edit_form_alter(&$form, &$form_state) {
$instance = $form['#instance'];
if ($instance['widget']['type'] == 'image_miw') {
$form['instance']['widget']['settings'] += array('imce_filefield_on' => array(
'#type' => 'checkbox',
'#title' => t('Allow users to select files from <a href="!url">IMCE File Browser</a> for this field.', array('!url' => url('admin/config/media/imce'))),
'#default_value' => $instance['widget']['settings']['imce_filefield_on'],
'#weight' => 16,
));
}
}
* Implements hook_form_FORM_ID_alter().
*/
function custom_form_field_ui_field_edit_form_alter(&$form, &$form_state) {
$instance = $form['#instance'];
if ($instance['widget']['type'] == 'image_miw') {
$form['instance']['widget']['settings'] += array('imce_filefield_on' => array(
'#type' => 'checkbox',
'#title' => t('Allow users to select files from <a href="!url">IMCE File Browser</a> for this field.', array('!url' => url('admin/config/media/imce'))),
'#default_value' => $instance['widget']['settings']['imce_filefield_on'],
'#weight' => 16,
));
}
}
/**
* Implements hook_field_widget_info_alter().
*/
function custom_field_widget_info_alter(&$info) {
if (isset($info['image_miw'])) {
$info['image_miw']['settings']['imce_filefield_on'] = 0;
}
}
* Implements hook_field_widget_info_alter().
*/
function custom_field_widget_info_alter(&$info) {
if (isset($info['image_miw'])) {
$info['image_miw']['settings']['imce_filefield_on'] = 0;
}
}
Add IMCE Field Process functions to mfw_managed_file Field
/**
* Implements hook_element_info().
*/
* Implements hook_element_info().
*/
function custom_element_info() {
$elements = array();
$elements['mfw_managed_file']['#process'] = array('imce_filefield_field_process');
$elements['mfw_managed_file']['#pre_render'] = array('imce_filefield_field_pre_render');
$elements['mfw_managed_file']['#file_value_callbacks'] = array('imce_filefield_field_value');
return $elements;
}
$elements = array();
$elements['mfw_managed_file']['#process'] = array('imce_filefield_field_process');
$elements['mfw_managed_file']['#pre_render'] = array('imce_filefield_field_pre_render');
$elements['mfw_managed_file']['#file_value_callbacks'] = array('imce_filefield_field_value');
return $elements;
}
No comments:
Post a Comment
Your comment is so valuable as it would help me in my growth of knowledge.