Want more features on Pastebin? Sign Up, it's FREE!
Guest

caption on right

By: alchymyth on Mar 5th, 2011  |  syntax: PHP  |  size: 0.97 KB  |  views: 765  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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.         }
clone this paste RAW Paste Data