How Do I Add Padding to an Image in WordPress?

Adding padding to an image in WordPress is easy. Just use the padding option in the media manager. For example, to add 1 pixel of padding to the left and right sides of an image, use the following code:

media.media_library.

add_image( ‘photo-1.jpg’, { ‘size': ‘medium’, ‘src': ‘photo-1.jpg’, ‘alt': ‘Sample Image’, ‘title': ‘Sample Image’ }, { ‘padding': 1 });.

The padding option can be used to add padding to any edge of an image.