What hook to use changing image field description I wonder how I can alter the description of the custom image field. I can't use hook_form_alter. I couldn't find the variable. Please advise. Thanks!

e.g
The alternate text field is added by image_field_widget_process(), which is the process element function added by image_field_widget_form() (an implementation of hook_field_widget_form()). To alter it, you can add your element process function with hook_field_widget_form_alter().

function mymodule_field_widget_form_alter(&amp;$element, &amp;$form_state, $context) {
  if ($context['field']['type'] == 'image' &amp;&amp; $context['instance']['widget']['type'] == 'image_image' &amp;&amp; !empty($context['instance']['settings']['alt_field'])) {
    foreach (element_children($element) as $delta) {
      $element[$delta]['#process'][] = 'mymodule_field_widget_process';
    }
  }
}

function mymodule_field_widget_process($element, &amp;$form_state, $form) {
  // Verify the element is accessible to the currently logged-in user.
  // Differently, it will not be visible to the user, and it is useless to alter the description, or the title.
  if ($element['alt']['#access']) {
    // Use $element['alt']['#title'] for the title.
    // Use $element['alt']['#description'] for the description.
  }

  return $element;
}


The reason I would use hook_field_widget_form_alter() instead of hook_form_alter() is that the first has direct access to some information the latter doesn't get, such as the settings for the field instance, and the field settings. In this case, I can access $context['instance']['settings']['alt_field'] to check if the field requires the alternate text field.

If you are going to use hook_form_alter(), remember that:


A field could have more than one widget, if the user is allowed to enter multiple values.
When its #access property is set to FALSE, a form element is not accessible to the currently logged-in user; in that case, it is useless to change any other properties for the form element, as it will not be shown to the user.