Stop WordPress from adding 10px padding to Images

For quite some time now I’ve been struggling with WordPress adding an additional 10px of padding to images that are uploaded via the content editor. After a small amount of digging, I’ve discovered the following override:

function remove_caption_padding( $width ) {
                  return $width - 10;
                }
                add_filter( 'img_caption_shortcode_width', 'remove_caption_padding' );

Add this to your functions.php file and instantly remove the 10px padding.

Filed Under:

  • wordpress