get_post_mime_type( int|WP_Post $post = null )
Retrieve the mime type of an attachment based on the ID.
Description Description
This function can be used with any post type, but it makes more sense with attachments.
Parameters Parameters
- $post
-
(int|WP_Post) (Optional) Post ID or post object. Defaults to global $post.
Default value: null
Return Return
(string|false) The mime type on success, false on failure.
Source Source
File: wp-includes/post.php
function get_post_mime_type( $post = null ) { $post = get_post( $post ); if ( is_object( $post ) ) { return $post->post_mime_type; } return false; }
Expand full source code Collapse full source code View on Trac
Changelog Changelog
Version | Description |
---|---|
2.0.0 | Introduced. |
User Contributed Notes User Contributed Notes
You must log in before being able to contribute a note or feedback.
Return an icon image path according to the MIME type of the given post
Expand full source codeCollapse full source code