Support » Plugins » How to add fields to Gallery Settings?

  • Hello,

    I’ve found this awesome post about how to add extra attachment information to an image uploaded from the media uploader.

    But, in this case i want to add an exrtra field to the Gallery Settings, when creating a gallery. For example, i wanna name the gallery so that the gallery string would be like
    [gallery link="file" ids="32,25,18,14,11,4,5" name="My awesome gallery"].

    How can i do this?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Place this code in your functions:

    add_action('print_media_templates', function(){
      // define your backbone template;
      // the "tmpl-" prefix is required,
      // and your input field should have a data-setting attribute
      // matching the shortcode name
      <script type="text/html" id="tmpl-my-custom-gallery-setting">
        <label class="setting">
          <span><?php _e('My setting'); ?></span>
          <select data-setting="my_custom_attr">
            <option value="foo"> Foo </option>
            <option value="bar"> Bar </option>
            <option value="default_val"> Default Value </option>
          // add your shortcode attribute and its default value to the
          // gallery settings list; $.extend should work as well...
          _.extend(, {
            my_custom_attr: 'default_val'
          // merge default gallery settings template with yours
            template: function(view){

    @peterbra – Thank you very much mate, you saved my day! 🙂

    @peterbra – Saved my day also, thank you very much! I spent a long time looking for that very snippet.


    Once you’ve done this no other theme/plugin can extend the template without knowing the name of your template and concatenating it to the list.

    How would dynamically push templates into the stack of templates?

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to add fields to Gallery Settings?’ is closed to new replies.