Advertisements

image_add_caption

Definition:
function image_add_caption( $html, $id, $caption, $title, $align, $url, $size, $alt = '' ) {}

Parameters

  • unknown_type $html
  • unknown_type $id
  • unknown_type $alt
  • unknown_type $title
  • unknown_type $align
  • unknown_type $url
  • unknown_type $size
  • $caption

Defined filters

  • disable_captions
    apply_filters( 'disable_captions', '' )
  • image_add_caption_shortcode
    apply_filters( 'image_add_caption_shortcode', $shcode, $html )

Source code

function image_add_caption( $html, $id, $caption, $title, $align, $url, $size, $alt = '' ) {



	if ( empty($caption) || apply_filters( 'disable_captions', '' ) )

		return $html;



	$id = ( 0 < (int) $id ) ? 'attachment_' . $id : '';



	if ( ! preg_match( '/width="([0-9]+)/', $html, $matches ) )

		return $html;



	$width = $matches[1];



	$caption = str_replace(	array( '>',    '<',    '"',      "'" ),

							array( '&gt;', '&lt;', '&quot;', ''' ),

							$caption

						  );



	$html = preg_replace( '/(class=["\'][^\'"]*)align(none|left|right|center)\s?/', '$1', $html );

	if ( empty($align) )

		$align = 'none';



	$shcode = '' . $html . '';



	return apply_filters( 'image_add_caption_shortcode', $shcode, $html );

}

1975

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: