[wp-trac] [WordPress Trac] #17044: div.wp-caption shortcode should have width of img, rather than add +10px

WordPress Trac wp-trac at lists.automattic.com
Fri Jan 6 10:18:28 UTC 2012


#17044: div.wp-caption shortcode should have width of img, rather than add +10px
-------------------------------+------------------------------
 Reporter:  mgk25              |       Owner:
     Type:  defect (bug)       |      Status:  new
 Priority:  normal             |   Milestone:  Awaiting Review
Component:  Shortcodes         |     Version:  3.1
 Severity:  normal             |  Resolution:
 Keywords:  close 2nd-opinion  |
-------------------------------+------------------------------

Comment (by oncletom):

 This 10px is just a total nonsense: WordPress core code should not provide
 bad hints to theme developers.

 Here are some thoughts to satisfy legacy code (which is there since 3.1,
 it means many themes did not have this 10px in mind BEFORE 3.1 – breaking
 things since this time does not seem to be problematic though):

 * switch `img_caption_shortcode` as a reference filter
 * if it's impossible, adding a `img_caption_shortcode_attributes` filter
 after `shortcode_atts` (and `extract` later)

 With one of these solutions:
 * attributes could be overloaded without rewriting the whole output
 * WordPress could embed a default filter to emulate this 10px and remove
 it in a certain number of release (deprecating right now this arbitrary
 number)
 * theme and developers could just REMOVE this filter to avoid this +10px
 width

 Something like this:

 {{{
 function img_caption_shortcode($attr, $content = null) {
 ...
         $attr = shortcode_atts(array(
                 'id'    => '',
                 'align' => 'alignnone',
                 'width' => '',
                 'caption' => ''
         ), $attr);
         $attr = apply_filters('img_caption_shortcode_attributes', $attr);
         extract($attr);
 ...
 }

 //in default-filters.php
 //@deprecated in wordpress 3.6
 add_filter('img_caption_shortcode_attributes', function($attr){
         if (isset($attr['width']) && (int)$attr['width'] > 0){
                 $attr['width'] += 10;
         }

         return $attr;
 });
 }}}

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


More information about the wp-trac mailing list