Advertisement
alchymyth

caption on right

Mar 5th, 2011
1,218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.97 KB | None | 0 0
  1. /*
  2.  * move captions to right of image
  3.  */
  4. add_shortcode('wp_caption', 'fixed_img_caption_shortcode');
  5. add_shortcode('caption', 'fixed_img_caption_shortcode');
  6. function fixed_img_caption_shortcode($attr, $content = null) {
  7.     // Allow plugins/themes to override the default caption template.
  8.     $output = apply_filters('img_caption_shortcode', '', $attr, $content);
  9.     if ( $output != '' ) return $output;
  10.     extract(shortcode_atts(array(
  11.         'id'=> '',
  12.         'align' => 'alignnone',
  13.         'width' => '',
  14.         'caption' => ''), $attr));
  15.     if ( 1 > (int) $width || empty($caption) )
  16.     return $content;
  17.     if ( $id ) $id = 'id="' . esc_attr($id) . '" ';
  18.     return '<div ' . $id . 'class="wp-caption ' . esc_attr($align)
  19.     . '" style="width: ' . ((int) $width+ 299 + 20) . 'px"><span style="float:left;">'
  20.     . do_shortcode( $content )
  21.     . '</span><p style="float:right; width: 301px;" class="wp-caption-text">'
  22.     . $caption
  23.     . '</p><span style="float:none;clear:both;display:block;"></span></div>';
  24.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement