file_is_valid_image

Validate that file is an image.

Description

file_is_valid_image( (string) $path ); 

Parameters (1)

0. $path (string)
File path to test if valid image.

Usage

  1. if ( !function_exists( 'file_is_valid_image' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/image.php'; 
  3.  
  4. // File path to test if valid image. 
  5. $path = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = file_is_valid_image($path); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-admin/includes/image.php  
  1. function file_is_valid_image($path) { 
  2. $size = @getimagesize($path); 
  3. return !empty($size);