Check if a remote image file exists in WordPress
<?php | |
/** | |
* Check if a remote image file exists. | |
* | |
* @param string $url The url to the remote image. | |
* @return bool Whether the remote image exists. | |
*/ | |
function km_remote_image_file_exists( $url ) { | |
$response = wp_remote_head( $url ); | |
return 200 === wp_remote_retrieve_response_code( $response ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment