wordpress / latest / functions / file_is_valid_image.html

file_is_valid_image( string $path ): bool

Validates that file is an image.

Parameters

$path string Required
File path to test if valid image.

Return

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

Source

File: wp-admin/includes/image.php. View all references

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

Uses

Uses Description

Changelog

Version Description
2.5.0 Introduced.

© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/file_is_valid_image