[wp-trac] [WordPress Trac] #18472: The gallery shortcode might need some extra filters.

WordPress Trac wp-trac at lists.automattic.com
Thu Aug 18 16:07:15 UTC 2011


#18472: The gallery shortcode might need some extra filters.
-------------------------+------------------------------
 Reporter:  kovshenin    |       Owner:
     Type:  enhancement  |      Status:  closed
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  Gallery      |     Version:
 Severity:  normal       |  Resolution:  duplicate
 Keywords:               |
-------------------------+------------------------------
Changes (by coffee2code):

 * status:  new => closed
 * resolution:   => duplicate


Comment:

 Check out #15155 (which I think is more appropriate here than #14130).  It
 looks to me like the shortcode attributes filter I proposed there should
 fulfill your request.  With it you can override the values that had been
 specified for the instances of the shortcode (whether it originated from
 the shortcode attribute defaults or values supplied by the user).  Here's
 a simple example using the filter.  I'm closing this as a duplicate, but
 feel free to reopen if you feel the solution is inadequate for what you
 wanted.

 {{{
 add_filter( 'shortcode_atts_gallery', 'gallery_shortcode_change_markup',
 10, 3 );

 /**
  * Change markup for gallery shortcode attributes of itemtag, icontag, and
  * captiontag regardless of default values or what user provided
  *
  * @param array $result The shortcode_atts() merging of $defaults and
 $atts
  * @param array $defaults The default attributes defined for the shortcode
  * @param array $atts The attributes supplied by the user within the
 shortcode
  * @return array The potentially modified $result array
  *
  */
 function gallery_shortcode_change_markup( $result, $defaults, $atts ) {
         $result['itemtag']    = 'div';
         $result['icontag']    = 'span';
         $result['captiontag'] = 'em';
         return $result;
 }
 }}}

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


More information about the wp-trac mailing list