file_is_valid_image() WordPress Function
The file_is_valid_image() function is a utility function that allows you to check if a given file is a valid image file. This is useful when you want to allow users to upload images to your website, for example. The function returns true if the file is a valid image, and false otherwise.
file_is_valid_image( string $path ) #
Validate 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
function file_is_valid_image( $path ) { $size = wp_getimagesize( $path ); return ! empty( $size ); }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
2.5.0 | Introduced. |