Disclaimer: This is basically me stream-of-thought’ing things as I’m learning the Core Media Modal’s codebase. It’s my scratchpad, and I’m merely making it public in the hopes that it may be useful to someone else at some point in the future. Some things are probably very wrong. If I catch it, I’ll likely come back and edit it later to be less wrong. If you see me doing or saying something stupid, please leave a comment, so I can be less stupid. Thanks!
The media is written in Backbone, using the `wp.template` wrapper around Underscore templates for rendering. If you want to really dive in depth, but don’t yet have a really solid understanding of Backbone, I’ve had several people recommend Addy Osmani’s book “Developing Backbone.js Applications” to me. As luck would have it, it’s available for free online.
When exploring the code in WordPress, it looks like it’s best to do the investigating in the develop.svn.wordpress.org repository’s src directory (yes, develop.svn matches to core.trac — basically because legacy reasons and not wanting to change core.trac’s url when they changed core.svn over to be the Grunt’d version), before the build tools such as Grunt have a chance to run Browserify on it #. If you try to read through the code on the GitHub mirror, you’re gonna have a bad time, as that doesn’t have the `wp-includes/js/media/` directory with the source files in it.
Oh, and all the actual templates that are parsed and rendered by the views are in `wp-includes/media-template.php`
Okay, time to dig in. (So that I’m not inadvertently writing a book, I’m going to split this into a series — but if you’d like to read them all, I’m dropping them in a tag. You can find them all here.)