You are here

function image_field_caption_widget_process in Image Field Caption 7.2

An element #process callback for the image field type.

Expands the image type to include the caption.

1 string reference to 'image_field_caption_widget_process'
image_field_caption_field_widget_form_alter in ./image_field_caption.module

File

./image_field_caption.module, line 191
Provides a caption textarea for image fields.

Code

function image_field_caption_widget_process($element, &$form_state, $form) {
  $item = $element['#value'];

  // Add the caption field with its value and text format. If there is no file
  // uri then we'll use the instance setting defaults, otherwise there is no
  // way to tell if this is a new image or not.
  $element['image_field_caption'] = array(
    '#title' => t('Caption'),
    '#type' => 'text_format',
    '#default_value' => isset($item['image_field_caption']['value']) ? $item['image_field_caption']['value'] : $element['#settings']['image_field_caption_default']['value'],
    '#access' => (bool) $item['fid'],
    '#format' => isset($item['image_field_caption']['format']) ? $item['image_field_caption']['format'] : $element['#settings']['image_field_caption_default']['format'],
  );
  return $element;
}