[wp-trac] Re: [WordPress Trac] #9424: Allow the media buttons to be filtered so they can be removed/altered

WordPress Trac wp-trac at lists.automattic.com
Fri Apr 3 20:17:03 GMT 2009


#9424: Allow the media buttons to be filtered so they can be removed/altered
-------------------------------------+--------------------------------------
 Reporter:  simonwheatley            |        Owner:            
     Type:  enhancement              |       Status:  reopened  
 Priority:  lowest                   |    Milestone:  Unassigned
Component:  Media                    |      Version:  2.8       
 Severity:  trivial                  |   Resolution:            
 Keywords:  needs-patch 2nd-opinion  |  
-------------------------------------+--------------------------------------
Changes (by Denis-de-Bernardy):

  * keywords:  has-patch => needs-patch 2nd-opinion
  * status:  closed => reopened
  * version:  => 2.8
  * resolution:  invalid =>


Comment:

 > The whole `media_buttons()` function can easily be replaced by using:
 > {{{
 > remove_action( 'media_buttons', 'media_buttons' );
 > add_action( 'media_buttons', 'my_custom_buttons' );
 > }}}

 But then, what happens when several plugins want to change those buttons?
 You end up with multiple insert image buttons with a conflicting ID that
 breaks javascripts?

 There definitely is a hook missing in there imo. Things should go some
 thing like:

 {{{
 $buttons = apply_filter('whatever_makes_sense', array(
   'image' => '<a href="foo"><img ...></a>',
   ...
   ));

 foreach ( $buttons as $button )
   echo $button;
 }}}

 Rather than:

 {{{
 printf($context, $out);
 }}}

 Arguably, a workaround would be to hook into media_buttons twice -- once
 to start an ob, and the next to filter it as needed. But it seems much
 more complicated than it should be.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/9424#comment:5>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list