function file_validate_is_image

Checks that the file is recognized by image_get_info() as an image.


$file: A Drupal file object.

Return value

An array. If the file is not an image, it will contain an error message.

See also


Related topics

1 call to file_validate_is_image()
FileValidatorTest::testFileValidateIsImage in drupal/modules/simpletest/tests/file.test
This ensures a specific file is actually an image.


drupal/includes/, line 1800
API for handling file uploads and server file management.


function file_validate_is_image(stdClass $file) {
  $errors = array();
  $info = image_get_info($file->uri);
  if (!$info || empty($info['extension'])) {
    $errors[] = t('Only JPEG, PNG and GIF images are allowed.');
  return $errors;