file_validate_is_image(&$file)
drupal/includes/file.inc, line 1041
Check that the file is recognized by image_get_info() as an image.
@see hook_file_validate()
$file A Drupal file object.
An array. If the file is not an image, it will contain an error message.
| Name | Description |
|---|---|
| File interface | Common file handling functions. |
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;
}