On the attachment page for an image, I'd like to display the image in its "large" size. The current behavior is showing the "medium" size image.
The template file used for displaying attachment pages is single.php (I verified this using the Show Current Template plugin). The relevant part of that template file called that outputs the image on the attachment page is (in template-parts/content-attachment.php):
the_content( sprintf( wp_kses( /* translators: %s: Name of current post. Only visible to screen readers */ __( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'vanguard-history' ), array( 'span' => array( 'class' => array(), ), ) ), wp_kses_post( get_the_title() ) ) );
What I see in the HTML in one example attachment page is:
<div class="entry-content"> <p class="attachment"> <a href="https://www.mike-eng.com/sandbox/vanguard-history/content/uploads/2021/11/Myron_Rosander_Addressing_2001_Santa_Clara_Vanguard_on_Final_Day_of_Tour.jpg"> <img src="https://www.mike-eng.com/sandbox/vanguard-history/content/uploads/2021/11/Myron_Rosander_Addressing_2001_Santa_Clara_Vanguard_on_Final_Day_of_Tour-300x225.jpg" class="attachment-medium size-medium" alt="" loading="lazy" srcset="https://www.mike-eng.com/sandbox/vanguard-history/content/uploads/2021/11/Myron_Rosander_Addressing_2001_Santa_Clara_Vanguard_on_Final_Day_of_Tour-300x225.jpg 300w, https://www.mike-eng.com/sandbox/vanguard-history/content/uploads/2021/11/Myron_Rosander_Addressing_2001_Santa_Clara_Vanguard_on_Final_Day_of_Tour-768x576.jpg 768w, https://www.mike-eng.com/sandbox/vanguard-history/content/uploads/2021/11/Myron_Rosander_Addressing_2001_Santa_Clara_Vanguard_on_Final_Day_of_Tour.jpg 1024w" sizes="(max-width: 300px) 100vw, 300px" width="300" height="225"> </a> </p> </div>
note the classes of "attachment-medium" and "size-medium" and the dimensions of my "medium" media size.
Where can I change the size displayed on attachment pages from "medium" to "large"? I can't find a setting anywhere for this. Also I would like to display the attachment’s caption (as set in the media library).
Also, in some older WordPress sites I've made, the default display was large, and they were also using the_content() to display the image. I’m not sure what's different here.
Is there a WordPress filter to set default attachment size shown on attachment pages? If so, what is it?
I verified in this comment thread that
returning before the function outputs any HTML, and it does seem
the_content() is what is displaying the attachment image. However, oddly,
get_the_content() is returning an empty string.
I removed the call of
vanguard_history_post_thumbnail() in content-attachment.php. This was a red herring copied over from a previous template part file. The attachment image is still displaying without it.