file_is_valid_image

The timeline below displays how wordpress function file_is_valid_image has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

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);
}

WordPress Version: 5.7

/**
 * Validate 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);
}

WordPress Version: 3.7

/**
 * Validate 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 = @getimagesize($path);
    return !empty($size);
}