get_post_mime_type

The timeline below displays how wordpress function get_post_mime_type has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.1

/**
 * 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.
 *
 * @since 2.0.0
 *
 * @param int|WP_Post $post Optional. Post ID or post object. Defaults to global $post.
 * @return string|false The mime type on success, false on failure.
 */
function get_post_mime_type($post = null)
{
    $post = get_post($post);
    if (is_object($post)) {
        return $post->post_mime_type;
    }
    return false;
}

WordPress Version: 5.1

/**
 * Retrieve 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.
 *
 * @since 2.0.0
 *
 * @param int|WP_Post $post Optional. Post ID or post object. Defaults to global $post.
 * @return string|false The mime type on success, false on failure.
 */
function get_post_mime_type($post = null)
{
    $post = get_post($post);
    if (is_object($post)) {
        return $post->post_mime_type;
    }
    return false;
}

WordPress Version: 4.1

/**
 * Retrieve 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.
 *
 * @since 2.0.0
 *
 * @param int|WP_Post $ID Optional. Post ID or post object. Default empty.
 * @return string|false The mime type on success, false on failure.
 */
function get_post_mime_type($ID = '')
{
    $post = get_post($ID);
    if (is_object($post)) {
        return $post->post_mime_type;
    }
    return false;
}

WordPress Version: 4.0

/**
 * Retrieve 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.
 *
 * @since 2.0.0
 *
 * @param int|WP_Post $ID Optional. Post ID or post object. Default empty.
 * @return string|bool The mime type on success, false on failure.
 */
function get_post_mime_type($ID = '')
{
    $post = get_post($ID);
    if (is_object($post)) {
        return $post->post_mime_type;
    }
    return false;
}

WordPress Version: 3.9

/**
 * Retrieve 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.
 *
 * @since 2.0.0
 *
 * @param int|WP_Post $ID Optional. Post ID or post object.
 * @return string|bool The mime type on success, false on failure.
 */
function get_post_mime_type($ID = '')
{
    $post = get_post($ID);
    if (is_object($post)) {
        return $post->post_mime_type;
    }
    return false;
}

WordPress Version: 3.7

/**
 * Retrieve 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.
 *
 * @since 2.0.0
 *
 * @param int $ID Optional. Post ID. Default is the current post from the loop.
 * @return string|bool The mime type on success, false on failure.
 */
function get_post_mime_type($ID = '')
{
    $post = get_post($ID);
    if (is_object($post)) {
        return $post->post_mime_type;
    }
    return false;
}