WordPress at a glance

get_post_mime_type() WP 1.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.

Works based on: get_post()

No Hooks.

Return

String/false. The mime type on success, false on failure.

Usage

get_post_mime_type( $ID );
$ID(int/WP_Post)
Post ID or post object.
Default: ''

Code of get_post_mime_type: wp-includes/post.php VER 4.9.8

<?php
function get_post_mime_type( $ID = '' ) {
	$post = get_post($ID);

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

	return false;
}

Related Functions

From tag: post

More from category: Attachments (Media files)

No comments
    Hello, !     Log In . Register