Add PDF Support Filter To WordPress Media Manager

By default, WordPress’ built-in media manager only has filter support for three types of media: image, audio, and video. But what about other file types like PDF? Well, thanks to a nifty trick from WP Tuts, it won’t have to be limited to just three anymore. I’m certain that this trick will be very helpful for those of you who work a lot with PDFs in your blog or site.

PDF support Add PDF Support Filter To WordPress Media Manager

Simply copy/paste the following code snippet below into your functions.php file (or just create a small plugin with it), and once you’re done you should then have PDF filtering added to your WordPress’ media manager.

function modify_post_mime_types( $post_mime_types ) {
// select the mime type, here: 'application/pdf'
// then we define an array with the label values
$post_mime_types['application/pdf'] = array( __( 'PDFs' ), __( 'Manage PDFs' ), _n_noop( 'PDF <span class="count">(%s)</span>', 'PDFs <span class="count">(%s)</span>' ) );
// then we return the $post_mime_types variable
return $post_mime_types;
}
// Add Filter Hook
 add_filter( 'post_mime_types', 'modify_post_mime_types' );

As you can see in the above code, the goal is achieve through the use of the ‘post_mime_types’ hook filter. You select the file type using the mime type slug for PDFs, which is ‘application/pdf’, and then an array is defined to contain the text labels for the file type. You can check out more details HERE.

Incoming search terms for the article:

Related Posts

Correctly Embed Watermarks In Portrait And Landscape Photos Using Conditional Actions In Photoshop CS6.1

Oregon-Inspired Photoshop Tutorial

Create Google Play’s Tab Navigation Using jQuery And CSS

PS Advanced Compositioning