-
Overriding Image Field Attribute Forms
Another quick example for you…
Here’s what the default image field form looks like, if you have enabled alt and title attributes:
One way to modify the titles and help text (descriptions) of the Alternate text and Title attributes here is to use hook_field_widget_form_alter. Here’s what your code might look like:
1234567891011121314151617181920212223/*** Implements hook_field_widget_form_alter().*/function mymodule_field_widget_form_alter(&$element, &$form_state, $context) {// see http://drupal.stackexchange.com/a/54911 for a more "universal approach"if (isset($element['#field_name']) && $element['#field_name'] == 'field_portfolio_images') {foreach (element_children($element) as $delta) {$element[$delta]['#process'][] = 'mymodule_field_widget_process_field_portfolio_image';}}}/*** Process callback for the field_portfolio_image title attribute form changes*/function mymodule_field_widget_process_field_portfolio_image($element, &$form_state, $form) {if ($element['title']['#access']) {$element['title']['#title'] = t('My New title');$element['title']['#description'] = t('Here are my custom instructions.');}return $element;}Here’s the result: