Created
February 28, 2013 09:05
-
-
Save ideag/5055360 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter('img_caption_shortcode', 'tiny_img_caption_shortcode_filter',10,3); | |
function tiny_img_caption_shortcode_filter($val, $attr, $content = null) { | |
extract(shortcode_atts(array( | |
'id' => '', | |
'align' => '', | |
'width' => '', | |
'caption' => '' | |
), $attr)); | |
if ( 1 > (int) $width || empty($caption) ) | |
return $val; | |
preg_match('/(size\-[^ ",]+)/', $content,$m); | |
return '<figure id="' . $id . '" class="wp-caption ' . esc_attr($align) . ' '.$m[0].' align-'.$align.'" style="width: ' . $width . 'px;">' | |
. do_shortcode( $content ) . '<figcaption class="wp-caption-text">' . $caption . '</figcaption></figure>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment