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.
Использование
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(массив)
- Attributes of the caption shortcode.
- $content(строка)
- The image element, possibly wrapped in a hyperlink.
Список изменений
| С версии 3.7.0 | Введена. |
Где вызывается хук
img_caption_shortcode_width
wp-includes/media.php 2618
$caption_width = apply_filters( 'img_caption_shortcode_width', $width, $atts, $content );