Example 1 — Show the image on its page
Print the file only on attachment pages.
<?php if ( is_attachment() ) {
echo wp_get_attachment_image( get_the_ID(), 'large' );
} ?> How It Works
is_attachment()is true on the page of a media file.get_the_ID()gives the attachment ID.wp_get_attachment_image()returns the image tag, so we useecho.

