Support » Requests and Feedback » Bug Report: post_mime_types

  • Is this the place for WordPress bug-reports? I hope so, because I think I’ve found a bug in the handling of post_mime_types with certain legitimate file MIMEs. The problem only becomes apparent when adding MIME-types to the $post_mime_types array via the post_mime_types filter. For example, the following is a legitimate MIME-type:uu8

    application/vnd.google-earth.kmlxml

    However, if I add the MIME to post_mime_types array with:

    function kml_modify_post_mime_types( $post_mime_types ) {
    	$post_mime_types['application/vnd.google-earth.kml+xml'] = array(__('KML'), __('Manage KML'), _n_noop('KML <span class="count">(%s)</span>', 'KML <span class="count">(%s)</span>'));
    	return $post_mime_types;
    }
    add_filter( 'post_mime_types', 'kml_modify_post_mime_types' );

    in my plugin, I don’t see a filter link at the top of the Media list (like the ones for Video, Audio etc.). I may be wrong, but I think this is because the ‘+’ character in the attachment MIME-type is not handled correctly.

    To test this, I tried faking a new MIME, minus the ‘+’. I changed the MIME-type my plugin add to the post_mime_types array to

    $post_mime_types['application/vnd.google-earth.kmlxml'] = array(__('KML'), __('Manage KML'), _n_noop('KML <span class="count">(%s)</span>', 'KML <span class="count">(%s)</span>'));

    then changed the value in the MIME field of a previously-uploaded KML file to the same (‘application/vnd.google-earth.kmlxml’). Now I DO see the filter link, and clicking on the link reveals the KML file as the only item in the filtered list, as it should.

    I’m not sure if the problem manifests itself anywhere else. I’ve not found any evidence it does, but it may well do. From doing some multi-file searches on the WP system files, my suspicion is that the problem is with one or both of the following functions in post.php:

    wp_match_mime_types()
    wp_post_mime_type_where()

    but I’m really not sure.

    I’d be grateful if a more skilled coder than me could confirm if this is actually a bug. It’s entirely possible that the Google-Earth KML/KMZ MIME-type strings are the only ones containing a ‘+’ (I haven’t done a comprehensive search), in which case, I’d understand if following this up isn’t ever likely to be a priority for the developers. It would be really nice to get it sorted though, if in fact it IS a genuine bug/oversight in the current WordPress system.

    Thanks guys.

    a|x

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Bug Report: post_mime_types’ is closed to new replies.