Get attachment image from media library

wp_get_attachment_image function can accept four values as you can see:

wp_get_attachment_image( int $attachment_id, string|array $size = 'thumbnail', bool $icon = false, string|array $attr = '' )

Examples

<?php echo wp_get_attachment_image( get_the_ID(), array('700', '600'), false, array( "class" => "img-fluid" ) ); ?>
<?php echo wp_get_attachment_image( 5151, 'medium', false, array( "class" => "img-fluid" ) ); ?>

Image responsive

Images in Bootstrap are made responsive with .img-fluid. max-width: 100%; and height: auto; are applied to the image so that it scales with the parent element.

<img src="..." class="img-fluid" alt="Responsive image">

Get Featured Image

Display the featured image of a post in a tag.

echo get_the_post_thumbnail();

Additionally if you want to grab a specific size for the featured image you can fill out the second argument with an image size. Also can add class onto image.

echo get_the_post_thumbnail( get_the_ID(), 'medium', array('class' => 'img-fluid') );

Return the URL of the featured post image.

echo get_the_post_thumbnail_url( get_the_ID(), 'medium' );