Created
July 6, 2018 19:08
-
-
Save kellenmace/028f0572ba6cbd896e162ca39836832d to your computer and use it in GitHub Desktop.
Check if a remote image file exists in WordPress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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