Tribe__Validator__Base::is_image( int|string $image )
Whether the provided value points to an existing attachment ID or an existing image URL.
Contents
Parameters
- $image
-
(int|string) (Required)
Return
(mixed)
Source
File: src/Tribe/Validator/Base.php
public function is_image( $image ) {
if ( $this->is_numeric( $image ) ) {
return wp_attachment_is_image( $image );
} elseif ( is_string( $image ) ) {
$response = wp_remote_head( $image );
if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) {
return false;
}
$content_type = wp_remote_retrieve_header( $response, 'content-type' );
if ( empty( $content_type ) || 0 !== strpos( $content_type, 'image' ) ) {
return false;
}
$allowed_mime_types = get_allowed_mime_types();
return ( in_array( $content_type, $allowed_mime_types ) );
}
return false;
}