function file_validate_is_image

Same name and namespace in other branches
  1. 7.x drupal-7.x/includes/file.inc \file_validate_is_image()

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

Parameters

$file: A Drupal file object.

Return value

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

Related topics

2 string references to 'file_validate_is_image'
system_theme_settings in drupal-6.x/modules/system/system.admin.inc
Form builder; display theme configuration for entire site and individual themes.
user_validate_picture in drupal-6.x/modules/user/user.module

Archivo

drupal-6.x/includes/file.inc, line 800
API for handling file uploads and server file management.

Código

function file_validate_is_image(&$file) {
  $errors = array();

  $info = image_get_info($file->filepath);
  if (!$info || empty($info['extension'])) {
    $errors[] = t('Only JPEG, PNG and GIF images are allowed.');
  }

  return $errors;
}