set maximum length to image title I'm trying to figure out how I can limit the maximum length of an image title to 40.
I have enabled title from the image field in my content and it works fine except that it seems to take unlimited number of letters. I want to reduce the maximum length of image title to 40. 
Does anyone have any idea how to do it?
Thanks
Something like this may work:

/**
 * Implements 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']['title_field'])) {
    foreach (element_children($element) as $delta) {
      $element[$delta]['#process'][] = 'mymodule_image_field_widget_process';
    }
  }
}

/**
 * Image field process callback
 */
function mymodule_image_field_widget_process($element, &amp;$form_state, $form) {
  // Set title maxlength, if accessible
  $maxlength = variable_get('imagefield_maxlength', 40);
  if ($element['title']['#access']) {
    $element['title']['#maxlength'] = $maxlength;
  }

  return $element;
}