How to add .pdf support to the WordPress media manager
Tento článek (nebo jeho část) je převzat z externího zdroje. Je tedy slušností jej uvést včetně případného autora.
By default, the built-in WordPress media manager allows you to filter media by three types: images, audio and video. But if you work a lot with .pdf files, you may need to add an option to filter .pdf files from the media manager. Here is a simple code snippet to do it.
Paste this code into your functions.php file. Save the file, and you’re done.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
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' ); |
Note that this code snippet can be used for other file types as well as .swf, .avi, .mov, etc.
Napsat komentář