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 = '<p class="attachment">';
	// 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>';
	$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.

By | 2017-09-24T23:19:17+00:00 May 7th, 2008|Wordpress|13 Comments

13 Comments

  1. Gabriolan December 3, 2008 at 12:13 am

    Thanks so much for this. It helped a lot!

  2. Widge December 3, 2008 at 1:24 am

    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.

  3. Naveen July 4, 2009 at 9:43 pm

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

  4. naveen July 5, 2009 at 1:05 pm

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

  5. Widge July 5, 2009 at 1:59 pm

    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.

  6. carlitos November 14, 2009 at 9:37 pm

    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.

  7. Widge November 14, 2009 at 11:06 pm

    Carlitos: Check this out…apparently you can create an attachment.php for your theme that removes the sidebar: http://codex.wordpress.org/Using_Image_and_File_Attachments

    Let me know if that’s helpful to you.

  8. Shahid March 26, 2011 at 3:07 pm

    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

  9. Widge March 27, 2011 at 5:42 am

    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…

  10. Shahid May 1, 2011 at 6:58 am

    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 :)

  11. Widge May 1, 2011 at 6:20 pm

    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.

  12. Els April 8, 2016 at 4:42 pm

    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!!

  13. Widge April 11, 2016 at 10:12 am

    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!

Leave A Comment

%d bloggers like this: