By default in WordPress media manager there are three types of filter exist image, audio and video. One of most common file we upload is PDF format file and it would be nice to have a PDF filter option in your media manager. And you have came to the right place. Lets see how we can add PDF media type filters to WordPress media manager.
Add the following code to your theme’s functions.php file
function modify_post_mime_types( $post_mime_types )
// select the mime type, here: 'application/pdf'
$post_mime_types['application/pdf'] = array( __( 'PDFs' ), __( 'Manage PDFs' ), _n_noop( 'PDF (%s)', 'PDFs (%s)' ) );
// then we return the $post_mime_types variable
return $post_mime_types;
// Add Filter Hook
add_filter( ‘post_mime_types’, ‘modify_post_mime_types’ );
Now you can see the PDF filter option in your media manager:
WordPress supports tons of file types. Here are some examples:
'pdf' => 'application/pdf',
'swf' => 'application/x-shockwave-flash',
'mov|qt' => 'video/quicktime',
'flv' => 'video/x-flv',
'avi' => 'video/avi',
'divx' => 'video/divx',
'js' => 'application/javascript',
Just add your desired post_mime_types in above code and you are done.
No comments:
Post a Comment