PLEASE NOTE: “As an Amazon Associate, [Need Coffee] earns from qualifying purchases." You know we make money from Amazon links,
and I know you know this, but they make us say it anyway. More info, click here.

Full Size Images in Attachment Pages in WordPress 2.5

Okay, so I was having the same sort of problem I was having previously–namely, even when you say you want attachment pages to show the full image, they still don’t. You have to click through to the file itself in order to see the full thing. I mentioned that with the pre-2.5 fix here.

Similar fix, but the code’s changed a little. Again, look for *whateveryoursiteis*/wp-includes/post-template.php file.

Look for this code. For me, it starts at line 504.

function prepend_attachment($content) {
	global $post;

	if ( empty($post->post_type) || $post->post_type != 'attachment' )
		return $content;

	$p = '

'; // show the medium sized image representation of the attachment if available, and link to the raw file $p .= wp_get_attachment_link(0, 'medium', false); $p .= '

'; $p = apply_filters('prepend_attachment', $p); return "$p\n$content"; }

You should change the medium there to full.

Now, if you’re like me and paranoid about coding you might ask yourself: before I was giving a maximum size…what happens now? Well, what happens now (I would assume) is that if you load an image that’s too big you’ll blow up your theme. They’ve obviously taken the shrinking bit out of the code and put it elsewhere. Where, I don’t know. So feel free to tinker if you’re the tinkering sort, but your safest bet is just to ensure your image width doesn’t go beyond what your theme’s content area would allow.

Let me know if you find any more/better ways to screw around with this.



  • Glad to hear it…I just did pretty much the same thing in 2.6.3 and it seemed to do the trick there as well. Thanks for your comment.

  • But sir, i want to change it to particular dimensions how the dimensions will give

  • hey i asked one question no bady answered and it is deleted, then why this site hear..? waste site

  • Naveen: First of all, if you had read the comment policy, you would understand that all comments have to be approved. Your comment hadn’t been approved yet. It was never deleted.

    Second of all, your question makes no sense the way it is structured, so I’m not sure how to answer it.

    I’ll make a stab, though: if you want to change an image to particular dimensions automatically by WordPress, then frankly, I don’t know how you do that. In fact, if you mean doing that when you upload it, as it creates a thumbnail and a medium size, then I would recommend NOT doing that because you would also have to change the labels in the media upload facility lest you be confused.

    Honestly, your best shot would be to just resize the images BEFORE you upload them.

    Sorry if that doesn’t answer your question. But we are a “waste site,” so we do what we can.

  • But you have any idea on how to remove the sidebar on attachments pages?

    I link the thumb gallery to the attachment page , great it shows full size but I dont want to show the sidebar. let me know if you know how to remove it please.

  • i am having a problem with my pictures attachment pages. If you open any of my Pictures in posts, then no one can come on the main post. Pictures in my site are not linked with the main post, y is it so? how can i link pictures to the main post, so that users landing on google can find the real post :S Kindly help me in this regard

  • Hi Shahid: I’m afraid I’m not quite following…if you’re talking about Google Image search landing on the main post and not the attachment, then I would advise you not to have your images as separate attachment pages…

  • Widge my users land on attachment page through search engines but my images aren’t lined with my main post. I want a link of main post in my attachment post plus thumbnails of other pictures in attachment page, so user can view all pictures and main post. Hope u got my point :)

  • Shahid: Actually…no. But I would say you should be able to edit the PHP that generates the attachment and create what you’re looking for. Just make sure you save a backup copy of your files and ensure when you update that you make the changes again. Good luck, chief.

  • I’m here 5 years later running om 4.4.2 and still struggling :) I don’t know if you still answer questions on this topic, or that you might have an updated post on this. Anyway, changing ‘medium’ (or ‘thumbnail’) to ‘full’ does the trick for the attachment page, but also increases the image in my gallery.. Is there a possibility to avoid that? Thanks in advance!!

  • Hey Els, I haven’t played around with native galleries too much… I’m using a modified version of the Avada theme, so I don’t even know at this point if we’re using apples and apples here. I know that I haven’t seen that problem in my current environment. Sorry I couldn’t be of more help!