Created
September 9, 2016 18:07
-
-
Save kellenmace/46018fa445c2ceab7d0283fab4858de2 to your computer and use it in GitHub Desktop.
Get File Type by URL for a Remote File 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 | |
/** | |
* Get the file mime type for a file by its URL. | |
* | |
* @param $url The URL to the file. | |
* @return The file mime type or empty string on failure. | |
*/ | |
function km_get_file_type_by_url( $url ) { | |
$response = wp_remote_get( $url ); | |
return wp_remote_retrieve_header( $response, 'content-type' ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment