Title: img_caption_shortcode_width
Published: April 25, 2014
Last modified: May 20, 2026

---

# apply_filters( ‘img_caption_shortcode_width’, int $width, array $atts, string $content )

## In this article

 * [Description](https://developer.wordpress.org/reference/hooks/img_caption_shortcode_width/?output_format=md#description)
    - [See also](https://developer.wordpress.org/reference/hooks/img_caption_shortcode_width/?output_format=md#see-also)
 * [Parameters](https://developer.wordpress.org/reference/hooks/img_caption_shortcode_width/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/hooks/img_caption_shortcode_width/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/hooks/img_caption_shortcode_width/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/hooks/img_caption_shortcode_width/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/hooks/img_caption_shortcode_width/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/hooks/img_caption_shortcode_width/?output_format=md#wp--skip-link--target)

Filters the width of an image’s caption.

## 󠀁[Description](https://developer.wordpress.org/reference/hooks/img_caption_shortcode_width/?output_format=md#description)󠁿

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.

### 󠀁[See also](https://developer.wordpress.org/reference/hooks/img_caption_shortcode_width/?output_format=md#see-also)󠁿

 * [img_caption_shortcode()](https://developer.wordpress.org/reference/functions/img_caption_shortcode/)

## 󠀁[Parameters](https://developer.wordpress.org/reference/hooks/img_caption_shortcode_width/?output_format=md#parameters)󠁿

 `$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.

## 󠀁[Source](https://developer.wordpress.org/reference/hooks/img_caption_shortcode_width/?output_format=md#source)󠁿

    ```php
    $caption_width = apply_filters( 'img_caption_shortcode_width', $width, $atts, $content );
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/media.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/media.php#L2618)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/media.php#L2618-L2618)

## 󠀁[Related](https://developer.wordpress.org/reference/hooks/img_caption_shortcode_width/?output_format=md#related)󠁿

| Used by | Description | 
| [img_caption_shortcode()](https://developer.wordpress.org/reference/functions/img_caption_shortcode/)`wp-includes/media.php` |

Builds the Caption shortcode output.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/hooks/img_caption_shortcode_width/?output_format=md#changelog)󠁿

| Version | Description | 
| [3.7.0](https://developer.wordpress.org/reference/since/3.7.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/hooks/img_caption_shortcode_width/?output_format=md#user-contributed-notes)󠁿

 1.  [Skip to note 2 content](https://developer.wordpress.org/reference/hooks/img_caption_shortcode_width/?output_format=md#comment-content-836)
 2.   [ElectricFeet](https://profiles.wordpress.org/electricfeet/)  [  11 years ago  ](https://developer.wordpress.org/reference/hooks/img_caption_shortcode_width/#comment-836)
 3. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fimg_caption_shortcode_width%2F%23comment-836)
    Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fimg_caption_shortcode_width%2F%23comment-836)
 4. If you want to remove the extra 10 pixels of width, add the following to your child
    theme’s _functions.php_:
 5.     ```php
        // removes WP's extra width on images with captions
        add_filter( 'img_caption_shortcode_width', '__return_zero' );
        ```
    
 6.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fimg_caption_shortcode_width%2F%3Freplytocom%3D836%23feedback-editor-836)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fimg_caption_shortcode_width%2F)
before being able to contribute a note or feedback.