One of the things WordPress does right out of the box that we don’t always like is automatically add an extra 10px of width to all images with captions. This is great if you want to preserve the default .wp-caption styling with a nice 5px of padded gray around the image, but if you change your CSS then you can end up with something not so great, like this:
Well here’s a quick workaround using the newish img_caption_shortcode_width filter:
/** * Remove WordPress's default padding on images with captions * * @param int $width Default WP .wp-caption width (image width + 10px) * @return int Updated width to remove 10px padding */ function remove_caption_padding( $width ) { return $width - 10; } add_filter( 'img_caption_shortcode_width', 'remove_caption_padding' );