height should be set to auto to avoid pixelation in the post thumbnail function

You can use a filter to remove height and width attributes from images, as explained in this CSS Tricks. Place the following in your themes functions.php file.

add_filter( 'post_thumbnail_html', 'remove_width_attribute', 10 );
add_filter( 'image_send_to_editor', 'remove_width_attribute', 10 );

function remove_width_attribute( $html ) {
   $html = preg_replace( '/(width|height)="\d*"\s/', "", $html );
   return $html;
}