function linkimagefield_widget_process in Link Image Field 7
Same name and namespace in other branches
- 6 linkimagefield_widget.inc \linkimagefield_widget_process()
Element #process callback function.
Parameters
array $element:
array $edit:
arrayreference $form_state:
array $form:
Return value
array
1 string reference to 'linkimagefield_widget_process'
- linkimagefield_field_widget_form in ./
linkimagefield.module - Implements hook_field_widget_form().
File
- ./
linkimagefield.module, line 219 - Defines a link image field type.
Code
function linkimagefield_widget_process($element, &$form_state, $form) {
$item = $element['#value'];
$item['fid'] = $element['fid']['#value'];
$instance = field_widget_instance($element, $form_state);
$settings = $instance['settings'];
$widget_settings = $instance['widget']['settings'];
$element['url'] = array(
'#title' => t('Link URL'),
'#type' => 'textfield',
'#default_value' => isset($item['url']) ? $item['url'] : $settings['url_settings']['url'],
'#description' => t('This URL will be loaded when the image is clicked'),
'#weight' => -4,
'#access' => (bool) $item['fid'],
);
$element['rel'] = array(
'#title' => t('Link Rel'),
'#type' => 'textfield',
'#default_value' => isset($item['rel']) ? $item['rel'] : '',
'#description' => t('Add rel attributes for bots, lightbox galleries, etc...'),
'#maxlength' => variable_get('image_longdesc_length', 500),
'#weight' => -4,
'#access' => (bool) $item['fid'] && $settings['url_settings']['rel_field'],
);
$element['class'] = array(
'#title' => t('Link Class'),
'#type' => 'textfield',
'#default_value' => isset($item['class']) ? $item['class'] : '',
'#description' => t('Add classes for theming, colorboxes, etc...'),
'#maxlength' => variable_get('image_longdesc_length', 500),
'#weight' => -4,
'#access' => (bool) $item['fid'] && $settings['url_settings']['class_field'],
);
$custom_target = $settings['url_settings']['custom_target'];
$options = array(
'default' => t('Use Default') . ' (' . $settings['url_settings']['target'] . ')',
) + _linkimagefield_widget_url_target_options();
$element['target'] = array(
'#title' => t('Link Target'),
'#type' => $custom_target ? 'select' : 'value',
'#options' => $custom_target ? $options : NULL,
'#default_value' => $custom_target && isset($item['target']) ? $item['target'] : $settings['url_settings']['target'],
'#description' => t('Window/Frame Target for the URL'),
'#weight' => -4,
'#access' => (bool) $item['fid'] && $custom_target,
);
$element['longdesc'] = array(
'#title' => t('Image Longdesc'),
'#type' => 'textfield',
'#default_value' => isset($item['longdesc']) ? $item['longdesc'] : '',
'#description' => t('The longdesc is used to provide a link to a long description of the image.'),
'#maxlength' => variable_get('image_longdesc_length', 500),
'#weight' => -1,
'#access' => (bool) $item['fid'] && $settings['longdesc_field'],
);
return $element;
}