WordPress 3.5 Media Manager: Is there a “good” way to add an additional select option within Create Gallery tab?

By good, I mean using hooks/filters.

Basically, by default the two options are Images and Uploaded to this page. I would like to add an additional option in there. I know how to add a new tab to the media manager (see here), but that doesn’t achieve what I need.

Read More

I’ve been looking through the limited documentation on 3.5 and have found the media_view_strings/settings filters, but, based on what I can tell, neither could be used in this case. I’ve also done quite a bit of digging through the core source, but the number of files relating to the media uploader is daunting to say the least.

I thought about running JS after page load to modify the DOM and just add the extra select option in, but this seems very hackish and I’d like to avoid it if there is a better, more robust solution.

Any thoughts on the best way to approach this would be greatly appreciated!

Note: I didn’t post this to the WordPress SE Site since it gets much less traffic and the questions tend to be much less programming-related.

Related posts

Leave a Reply

2 comments

  1. Most of those select-dropdowns are from wp-includes/media-template.php, which has a lot of Underscore templating (<script type="text/html" tags), but few action hooks for php code. With Javascript you can bind the Backbone.js hooks for wp.media events, such as wp.media’s open/close events. From such event you could grab that Images/uploaded-to-page selectbox with jQuery('.media-modal-content:visible .attachment-filters'), add item(s) and listeners as needed. I’m pretty sure there should be a much better Backbone.js-style solution, though.