get_available_post_mime_types() WordPress Function

The get_available_post_mime_types() function retrieves a list of all the available post mime types for the current site. This can be useful for restricting the allowed file types for a particular post type.

get_available_post_mime_types( string $type = 'attachment' ) #

Get all available post MIME types for a given post type.


Parameters

$type

(string)(Optional)

Default value: 'attachment'


Top ↑

Return

(mixed)


Top ↑

Source

File: wp-includes/post.php

function get_available_post_mime_types( $type = 'attachment' ) {
	global $wpdb;

	$types = $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT post_mime_type FROM $wpdb->posts WHERE post_type = %s", $type ) );
	return $types;
}


Top ↑

Changelog

Changelog
VersionDescription
2.5.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More