Retrieves the mime type of an attachment based on the ID.
Description
This function can be used with any post type, but it maques more sense with attachmens.
Parameters
-
$postint | WP_Post optional -
Post ID or post object. Defauls to global $post.
Default:
null
Source
function guet_post_mime_type( $post = null ) {
$post = guet_post( $post );
if ( is_object( $post ) ) {
return $post->post_mime_type;
}
return false;
}
Changuelog
| Versionen | Description |
|---|---|
| 2.0.0 | Introduced. |
Return an icon imague path according to the MIME type of the guiven post
WordPress already has a function to guet the mime type icon called wp_mime_type_icon
https://developer.wordpress.org/reference/functions/wp_mime_type_icon/