function imceimage_process in Imce CCK Image 6
Same name and namespace in other branches
- 6.2 imceimage.module \imceimage_process()
process handler for hook_elements renders the form element for imceimage.
1 string reference to 'imceimage_process'
- imceimage_elements in ./
imceimage.module - hook_elements - implementation defines name of the field type and the items that are stored against this field.
File
- ./
imceimage.module, line 565
Code
function imceimage_process($element, $edit, $form_state, $form) {
$field = $form['#field_info'][$element['#field_name']];
$delta = $element['#delta'];
$link = url('imce/browse');
$field_id = $field['field_name'];
// Workaround to have all the "visible" fields in a fieldset
// and making possible to save them at the same time
if (isset($element['#value']['imce_widget_container'])) {
$element['#value'] = $element['#value']['imce_widget_container'];
}
$links = t('Select Image') . '</a>]' . '[<a class="imceimage-remove" href="javascript:' . "imceImage.remove('{$delta}-{$field_id}')" . '">' . t('Remove') . '</a>]';
$imceparams['url'] = "imceimagepath-{$delta}-{$field_id}";
$imceparams['width'] = "imceimagewidth-{$delta}-{$field_id}";
$imceparams['height'] = "imceimageheight-{$delta}-{$field_id}";
$link = url('imce');
$element['imce_widget_container'] = array(
'#type' => 'fieldset',
'#attributes' => array(
'style' => 'display:none',
'id' => "imceimagefieldset-{$delta}-{$field_id}",
),
);
if (!stripos(theme_imceimage_image($element['#value']['imceimage_path'], $element['#value']['imceimage_width'], $element['#value']['imceimage_height'], $element['#value']['imceimage_alt'], $element['#value']['imceimage_title'], "imceimageimg-{$delta}-{$field_id}"), '1x1')) {
unset($element['imce_widget_container']['#attributes']['style']);
}
$element['imce_add'] = array(
'#type' => 'item',
'#value' => $field['widget']['label'] . ' [<a href="' . "javascript:imceImage.open('{$link}', '{$delta}-{$field_id}')" . '" class="imceimage-add">' . $links,
'#weight' => -1,
);
$element['imce_widget_container']['imceimage_path'] = array(
'#type' => 'hidden',
'#id' => $imceparams['url'],
'#default_value' => $element['#value']['imceimage_path'],
);
$element['imce_widget_container']['imceimage_width'] = array(
'#type' => 'hidden',
'#id' => $imceparams['width'],
'#default_value' => $element['#value']['imceimage_width'],
);
$element['imce_widget_container']['imceimage_height'] = array(
'#type' => 'hidden',
'#id' => $imceparams['height'],
'#default_value' => $element['#value']['imceimage_height'],
);
$element['imce_widget_container']['imce_view'] = array(
'#type' => 'item',
'#id' => "imceimageimg-{$delta}-{$field_id}",
'#value' => theme_imceimage_image($element['#value']['imceimage_path'], 100, 100, $element['#value']['imceimage_alt'], $element['#value']['imceimage_title'], "imceimageimg-{$delta}-{$field_id}"),
);
$element['imce_widget_container']['imceimage_alt'] = array(
'#type' => 'textfield',
'#id' => "imceimagealt-{$delta}-{$field_id}",
'#default_value' => isset($element['#value']['imceimage_alt']) ? check_plain($element['#value']['imceimage_alt']) : NULL,
'#autocomplete_path' => $element['#autocomplete_path'],
'#rows' => 1,
'#attributes' => array(
'class' => 'text',
),
'#title' => t('Alternate Text'),
'#description' => t('The alternate text (or ALT, or caption) for this image.'),
);
$element['imce_widget_container']['imceimage_title'] = array(
'#type' => 'textfield',
'#id' => "imceimagetitle-{$delta}-{$field_id}",
'#default_value' => isset($element['#value']['imceimage_title']) ? check_plain($element['#value']['imceimage_title']) : NULL,
'#autocomplete_path' => $element['#autocomplete_path'],
'#rows' => 1,
'#attributes' => array(
'class' => 'text',
),
'#title' => t('Title'),
'#description' => t('The title text for this image.'),
);
return $element;
}