img_caption_shortcode_width
Filters the width of an image's caption.
By default, the caption is 10 pixels greater than the width of the image, to prevent post content from running up against a floated image.
Usage
add_filter( 'img_caption_shortcode_width', 'wp_kama_img_caption_shortcode_width_filter', 10, 3 ); /** * Function for `img_caption_shortcode_width` filter-hook. * * @param int $width Width of the caption in pixels. To remove this inline style, return zero. * @param array $atts Attributes of the caption shortcode. * @param string $content The image element, possibly wrapped in a hyperlink. * * @return int */ function wp_kama_img_caption_shortcode_width_filter( $width, $atts, $content ){ // filter... return $width; }
- $width(int)
- Width of the caption in pixels. To remove this inline style, return zero.
- $atts(array)
- Attributes of the caption shortcode.
- $content(string)
- The image element, possibly wrapped in a hyperlink.
Changelog
Since 3.7.0 | Introduced. |
Where the hook is called
img_caption_shortcode_width
wp-includes/media.php 2465
$caption_width = apply_filters( 'img_caption_shortcode_width', $width, $atts, $content );