file_is_valid_image( string $path ): bool

In this article

Validates that file is an image.

Parameters

$pathstringrequired
File path to test if valid image.

Return

bool True if valid image, false if not valid image.

Source

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

Changelog

VersionDescription
2.5.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.