file_is_valid_image()WP 2.5.0

Validates that file is an image.

No Hooks.

Return

true|false. True if valid image, false if not valid image.

Usage

file_is_valid_image( $path );
$path(string) (required)
File path to test if valid image.

Changelog

Since 2.5.0 Introduced.

file_is_valid_image() code WP 6.5.2

function file_is_valid_image( $path ) {
	$size = wp_getimagesize( $path );
	return ! empty( $size );
}