Advertisement
alchymyth

caption

Apr 21st, 2011
417
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.87 KB | None | 0 0
  1. add_shortcode('wp_caption', 'slim_img_caption_shortcode');
  2. add_shortcode('caption', 'slim_img_caption_shortcode');
  3. function slim_img_caption_shortcode($attr, $content = null) {
  4.  // Allow plugins/themes to override the default caption template.
  5.  $output = apply_filters('img_caption_shortcode', '', $attr, $content);
  6.  if ( $output != '' )
  7.  return $output;
  8.  
  9.  extract(shortcode_atts(array(
  10.  'id'    => '',
  11.  'align'    => 'alignnone',
  12.  'width'    => '',
  13.  'caption' => ''
  14.  ), $attr));
  15.  
  16.  if ( 1 > (int) $width || empty($caption) )
  17.  return $content;
  18.  
  19.  if ( $id ) $id = 'id="' . esc_attr($id) . '" ';
  20.  
  21.  $frame_width = 0; // frame width in pixels per side //
  22.  
  23.  return '<div ' . $id . 'class="wp-caption ' . esc_attr($align) . '" style="width: ' . ( 2 * $framewidth + (int) $width) . 'px">'
  24.  . do_shortcode( $content ) . <p class="wp-caption-text"> . $caption . '</p></div>';
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement