How I can intercept an image field upload and validate it? I have a content type with an image field. I need to validate this field because I need to check if user upload a real image or only a file with image's extension (like jpg, gif, png etc). I have tried and readed 100+ things but none resolve my problem. 

I have tried via "#upload_validators" with this code:

foreach ($form['field_all_images'][$form['field_all_images']['#language']] as $k =&gt; $v) {
  if (!is_integer($k)) continue;

  $form['field_all_images'][$form['field_all_images']['#language']][$k]['#upload_validators']['check_image_correct'] = array();
}


where "check_image_correct()" is a my custom function that checks via imagegetinfo(). My problem, in this "try/case", is that the function works/is called only for the first image. I have tried to move this function from hook_form_alter() to an #after_build function, without result (only the first time it works).
It looks like there a couple of very small bugs in that code that would stop it working properly, try this:

$lang = $form['field_all_images']['#language'];
foreach (element_children($form['field_all_images'][$lang]) as $key) {
  $form['field_all_images'][$lang][$key]['#upload_validators'][] = 'check_image_correct';
}