[wp-trac] [WordPress Trac] #37960: Support for selecting radio buttons in media views

WordPress Trac noreply at wordpress.org
Fri Sep 30 19:15:31 UTC 2016


#37960: Support for selecting radio buttons in media views
-------------------------------------+-------------------------------------
 Reporter:  Enchiridion              |       Owner:  joemcgill
     Type:  enhancement              |      Status:  reviewing
 Priority:  normal                   |   Milestone:  Awaiting Review
Component:  Media                    |     Version:
 Severity:  normal                   |  Resolution:
 Keywords:  has-patch reporter-      |     Focuses:  javascript,
  feedback                           |  administration
-------------------------------------+-------------------------------------

Comment (by Enchiridion):

 Ah, thanks, didn't realize it was a built up file.

 I've attached an additional patch to update the CSS so the radio buttons
 display correctly.  There was a tiny amount of existing CSS for radio
 buttons in the modals, but I couldn't find any instances of radio buttons
 in actual use anywhere to make sure my changes didn't adversely affect
 anything.

 Here are the snippets to add radio buttons to the modal for testing:

 Add this to your theme/plugin:

 {{{#!php
 <?php
 // Output custom media templates
 add_action( 'print_media_templates', function () {
   ?>
   <script type="text/html" id="tmpl-vi-custom-gallery-settings">
     <div class="setting">
       <fieldset>
         <legend>Grid Layout</legend>
         <label><input type="radio" name="grid-layout" data-setting="grid-
 layout" value="2-up"><span>2-up</span></label>
         <label><input type="radio" name="grid-layout" data-setting="grid-
 layout" value="3-up"><span>3-up</span></label>
         <label><input type="radio" name="grid-layout" data-setting="grid-
 layout" value="masonry"><span>Masonry</span></label>
         <label><input type="radio" name="grid-layout" data-setting="grid-
 layout" value="full-width"><span>Full width</span></label>
       </fieldset>
     </div>
   </script>
   <?php
 } );
 }}}

 Run this Javascript on the admin side:
 {{{#!js
 wp.media.view.Settings.Gallery = wp.media.view.Settings.Gallery.extend({
   render: function() {
     // Required for the base options to appear
     wp.media.view.Settings.prototype.render.apply( this, arguments );

     // Append the custom template after the title
     this.$el.find('> h2').after( wp.media.template( 'vi-custom-gallery-
 settings' ) );

     // Setup custom settings
     wp.media.gallery.defaults['grid-layout'] = '2-up';
     this.update.apply( this, ['grid-layout'] );

     return this;
   }
 });
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/37960#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list