Forums

post_mime_types Filter (9 posts)

  1. toneburst
    Member
    Posted 3 months ago #

    HI,

    I'm trying to add a tab to the Media library (like the standard Images, Audio and Video ones), for Google Maps KML files, using the post_mime_types filter.

    function modify_post_mime_types( $post_mime_types ) {
    	    $post_mime_types[ 'application/vnd.google-earth.kml+xml' ] = array( 'Google Maps KML', 'Manage KML', 'KML (%s)' );
    	    return $post_mime_types;
    	}
    
        add_filter( 'post_mime_types', array( &$this, 'modify_post_mime_types' ) );

    The function is inside a class, hence the '&$this'.

    Unfortunately, this doesn't seem to be working. I can upload KML files (though I had to add a upload_mimes filter to allow uploading of the files), and I can see uploaded KML files in the Media Library, but they don't get a tab at the top.

  2. toneburst
    Member
    Posted 3 months ago #

    I should have made clear. I'm writing a plugin to do this. Not sure it makes any difference.

    a|x

  3. toneburst
    Member
    Posted 3 months ago #

    Anyone?

    a|x

  4. toneburst
    Member
    Posted 3 months ago #

    Any tips, anyone? Still can;t get this to work. The KML tab at the top of the Media Library list stubbornly refuses to appear.

    a|x

  5. toneburst
    Member
    Posted 3 months ago #

    Any ideas?

    a|x

  6. toneburst
    Member
    Posted 3 months ago #

    Anyone at all?

    this function appears to work fine (but obviously only filters PDF files, not the intended KML ones):

    function modify_post_mime_types( $post_mime_types ) {
    	$post_mime_types['application/pdf'] = array(__('PDF'), __('Manage PDF'), _n_noop('PDF <span class="count">(%s)</span>', 'PDF <span class="count">(%s)</span>'));
    	return $post_mime_types;
    }
    add_filter( 'post_mime_types', array( &$this, 'modify_post_mime_types' ) );

    But if I replace 'application/pdf' with 'application/vnd.google-earth.kmz+xml', it fails, though I am able to upload KML files, after implementing the upload_mimes filter.

    I'd be very grateful if someone could help. I can't believe I'm the only person using these filters.

    a|x

  7. toneburst
    Member
    Posted 3 months ago #

    I'm going to keep bumping this one, because I can't find any info anywhere on this, and don't know why it's not working.

    a|x

  8. toneburst
    Member
    Posted 3 months ago #

    Turns out PDF files are supported natively, so my test function wasn't really doing anything, anyway. I guess this means I'm no nearer knowing why this doesn't work.

    a|x

  9. toneburst
    Member
    Posted 2 months ago #

    Bump.

    a|x

Reply

You must log in to post.

About this Topic