WordPress Version: 6.1
/**
* Validates that file is an image.
*
* @since 2.5.0
*
* @param string $path File path to test if valid image.
* @return bool True if valid image, false if not valid image.
*/
function file_is_valid_image($path)
{
$size = wp_getimagesize($path);
return !empty($size);
}