Post Mime Types for KML File
-
Hi,
I’m trying to add a media filter link to the top of the Media page, like the existing ones for Images, Videos, Audio, etc. Here’s the code I’m using:
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; }
Called by:
add_filter( 'post_mime_types', array( &$ELLGmapKML, 'kml_modify_post_mime_types' ) );
I also had to use the following to allow file of this type to be uploaded:
function kml_modify_upload_mime_types( $upload_mime_types ) { $mimes = array_merge( $upload_mime_types, array( 'kml' => 'application/vnd.google-earth.kml+xml', 'kmz' => 'application/vnd.google-earth.kmz+xml' )); return $mimes; }
add_filter( 'upload_mimes', array( &$ELLGmapKML, 'kml_modify_upload_mime_types' ) );
(the functions are inside a class, hence the ‘&$ELLGmapKML’).
It’s just not working. I’m able to upload files of this MIME-type, but no filter link appears.
Also, another part of the plugin I’m developing is supposed to return a list of media of this same MIME-type, and this also fails to work, so somewhere along the way, WordPress is failing to recognise the MIME-type of this kind of file. If I click on the KML file in the Media list, though, the Edit page for the media does in fact show the correct MIME information (application/vnd.google-earth.kml+xml) in the ‘File Type’ field of the edit form.
Also, I’ve been able to add custom fields to the edit form for this type of media, based again, on the MIME-type string from the meta-information for the file, so it seems that for the purposes of the filter links at the top of the Media list, and for querying the database for posts by MIME, the MIME type is not recognised, whereas in other contexts, it is.
Very frustrating. Can anyone throw any light on this issue? Could it possibly have anything to do with the ‘+’ character in ‘application/vnd.google-earth.kml+xml’? Probably a stupid question, but I’m a bit stuck here. I can think of a workaround for the issue of querying posts- ie search for posts with a specific custom meta-field, which I can add only to posts with that MIME-type, but can’t think of a workaround for the issue of the Media list filter links. I’d rather this just worked as intended, anyway.
Thanks in advance for your help, guys,
Cheers,
a|x
[ Please do not bump, it’s not permitted here. ]
- The topic ‘Post Mime Types for KML File’ is closed to new replies.