MediaWiki’s Mime detection system, which is used as a core component of upload verification as well as to direct media files to the appropriate media handler (for proper transformations, extraction of metadata, etc) works okay for the limited number of formats that are currently officially supported. Basically we’re talking images, some vector graphics formats, djvu files, and ogg A/V. Unfortunately, reliably identifying this small subset of media types has already required many sprinklings of code specific to a single content-type to tweak incorrect magic mime guesses,  etc.

 Try feeding the existing MimeMagic module a .asf video file or a lossless/uncompressed YUV video stream. (Hint: it no workie.) Since many more media types will be added in the near future through my project and others, I decided something definitive needed to be done. Rather than continuing to add more and more special-case code to the one (already bloated) class every time a new problem comes up, I’m creating a framework for the main module to make use of plugins as necessary that specialize in particular content-types. Without getting too technical about a plugin’s abilities, they will function as self-contained classes capable of supplying the main module with information about the content type(s) they target in general as well as in the context of a specific given file. 

A number of todo’s in the main module highlight other shortcomings that I’m shooting to address, or at least design the plugin framework to make it easier to address all of them as well. 

This wasn’t something I foresaw myself working on per-se, but it is something that really should be done before I get into the heart of my proposed project. I’ll make my case for it on wikitech-l and post my code to my branch on SVN in the coming days. (That’s right, I’m too chicken to ask first, I’m just writing it and hoping it will guilt-trip it’s way into mainline code 🙂 Actually, I think conceptually my idea is perfectly valid, so the only thing to worry about is if people don’t like my implementation…but I’m putting much care into it too. Stay tuned to hear how it goes…