Thumbnails generated from PDF in the “Media” section – how to show them in theme template?

To get the attachment’s icon, you can use wp_get_attachment_image().

For example, let’s say I’ve uploaded a Word doc and it’s got the ID 1234:

 // Parameter 3 - 'true' - tells WP to treat this as an icon.
 $img_tag = wp_get_attachment_image( 1234, 'thumbnail', true );
 // $img_tag contains:
 //   <img width="48" height="64"
 //        src="http://example.com/wp-includes/images/media/document.png"
 //        class="attachment-thumbnail size-thumbnail"
 //        alt="" loading="lazy"
 //   />