Is there a way to add clauses like accept = 'image/*' to input items via forms API? I'd like to add "accept" attributes to some of the input fields for my site's content types -- to end up with something like &lt;input type="file" id="edit-field-whatever-und-0-upload" name="files[field_whatever_und_0]" size="22" class="form-file" accept="image/*"&gt;, so that (most) browsers will limit the selectable items to .jpg, .png, etc.  I've tried doing this by adding an #attributes clause to a form's hook_form_alter handler, but haven't been able to find the right way to write the clause -- I can't get the accept clause to show up in the html.

In place of this, I'm currently adding it through some jQuery that runs on document.ready, but it would feel cleaner if I could do it through the forms api. Is this possible? Any hints out there?  Thanks!
You can override theme_file to achieve above if you would like to alter file input element in template.php ..

function YOURTHEMENAME_file($variables) {
  $element = $variables['element'];
  $element['#attributes']['type'] = 'file';
  element_set_attributes($element, array('id', 'name', 'size'));
  _form_set_class($element, array('form-file'));

  return '&lt;input' . drupal_attributes($element['#attributes']) . ' accept="image/*" /&gt;';
}


below code works for me

function seven_file($variables) {
  $element = $variables['element'];
  $element['#attributes']['type'] = 'file';
  element_set_attributes($element, array('id', 'name', 'size'));
  _form_set_class($element, array('form-file'));

  return '&lt;input' . drupal_attributes($element['#attributes']) . ' accept="image/*" /&gt;';
}