Use the_post_thumbnail
. For example:
<?php if ( has_post_thumbnail()) : ?>
<a href="https://wordpress.stackexchange.com/questions/250403/<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" >
<?php the_post_thumbnail(); ?>
</a>
<?php endif; ?>