get_post_mime_type( int|WP_Post $ID = '' )
Retrieve the mime type of an attachment based on the ID.
Description
This function can be used with any post type, but it makes more sense with attachments.
Parameters
- $ID
-
(Optional) Post ID or post object.
Default value: ''
Return
(string|false) The mime type on success, false on failure.
Source
File: wp-includes/post.php
function get_post_mime_type( $ID = '' ) {
$post = get_post($ID);
if ( is_object($post) )
return $post->post_mime_type;
return false;
}
Changelog
Version | Description |
---|---|
WP-2.0.0 | Introduced. |