get_post_mime_type() – Retrieve the mime type of an attachment based on the ID.

You appear to be a bot. Output may be restricted

Description

Retrieves the mime type of an attachment based on the ID.

This function can be used with any post type, but it makes more sense with attachments.

Usage

$string|false = get_post_mime_type( $post );

Parameters

$post
( int|WP_Post ) optional – Optional. Post ID or post object. Defaults to global $post.

Returns

string|false The mime type on success, false on failure.

Source

File name: wordpress/wp-includes/post.php
Lines:

1 to 9 of 9
function get_post_mime_type( $post = null ) {
  $post = get_post( $post );

  if ( is_object( $post ) ) {
    return $post->post_mime_type;
  }

  return false;
}
 

 View on GitHub View on Trac