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

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

Leave a comment