A HitchHackers guide through WordPress


Home | Pages | Archives


img_caption_shortcode

February 12, 2011 1:15 am

Definition:
function img_caption_shortcode($attr, $content = null) {}

The Caption shortcode.
Allows a plugin to replace the content that would otherwise be returned. The filter is ‘img_caption_shortcode’ and passes an empty string, the attr parameter and the content parameter values.

Parameters

Defined filters

Source code

function img_caption_shortcode($attr, $content = null) {



	// Allow plugins/themes to override the default caption template.

	$output = apply_filters('img_caption_shortcode', '', $attr, $content);

	if ( $output != '' )

		return $output;



	extract(shortcode_atts(array(

		'id'	=> '',

		'align'	=> 'alignnone',

		'width'	=> '',

		'caption' => ''

	), $attr));



	if ( 1 > (int) $width || empty($caption) )

		return $content;



	if ( $id ) $id = 'id="' . esc_attr($id) . '" ';



	return '<div ' . $id . 'class="wp-caption ' . esc_attr($align) . '" style="width: ' . (10 + (int) $width) . 'px">'

	. do_shortcode( $content ) . '<p class="wp-caption-text">' . $caption . '</p></div>';

}

2005

Rate this:

Posted by Thorsten

Categories: /wp-includes/media.php, Documentation, Files, Filters, Filters by letter i, Functions, Functions by letter i

Tags: ,

Leave a Reply



Mobile Site | Full Site


Get a free blog at WordPress.com Theme: WordPress Mobile Edition by Alex King.