function imagefield_tokens_field_widget_process in ImageField Tokens 7
An element #process callback for the image_image field type.
1 string reference to 'imagefield_tokens_field_widget_process'
File
- ./
imagefield_tokens.module, line 168 - Implements image Alt and Title field defaults with support for tokens.
Code
function imagefield_tokens_field_widget_process($element, &$form_state, $form) {
$instance = field_info_instance($element['#entity_type'], $element['#field_name'], $element['#bundle']);
$settings = $instance['settings'];
$item = $element['#value'];
// Possibly prefill the alt and title fields.
$element['alt']['#default_value'] = isset($item['alt']) ? $item['alt'] : $settings['alt_field_default'];
$element['title']['#default_value'] = isset($item['title']) ? $item['title'] : $settings['title_field_default'];
// Possibly hide the alt and title fields.
if ($settings['alt_field_hide']) {
$element['alt']['#access'] = FALSE;
}
if ($settings['title_field_hide']) {
$element['title']['#access'] = FALSE;
}
return $element;
}