I would like to enhance the Media Editor, after WordPress 3.5, on the gallery view.
I want to add a new select field on the right side and send the selected values to the gallery shortcode.
I think, the function wp.media.gallery
in wp-includes/js/media-editor.js
is the default function to insert the gallery shortcode.
I want to add a new parameter and the values of the parameter come from the select field inside the Media Manager.
I have played with different sources, especially from this question, but Backbone is very new for me and I don’t understand how it works. I have also played with the hook print_media_templates
, but no result on the Media view.
What hooks should I use?
A small source, perhaps for a plugin to create the solution. At first the php part, there include the javascript for the button inside the Media Manager. Is more usable answer, but the answer of @One Trick Pony was create and the right direction and JS solution.
See the result on the image:
The resulting shortcode, if the size not default size:
The Hook
print_media_templates
is the right place for include the button, the markup. Also was enqueue a script, there have the solution for append the controls.The follow source is the javascript, on the example source in php, the file
custom-gallery-setting.js
If you really want to use Backbone templates, then your hook is correct.
I would use jQuery to insert the HTML template rather than overriding the
template()
function for the gallery settings view. But I guess you already know that, so I’ll post the Backbone version: