Make the WordPress attachment page display full image

Last updated on November 28, 2011. Tags: , ,

As stated in my previous post, the default configuration of the attachment page is that it displays the medium size version of the image (as configured in Settings » Media) and that medium-size image is a link to the actual image file in full size. In the previous post, we discussed how to remove the link and make it a simple image emdedded on the attachment page. In this post, we will tackle how to make it full size.

To make the attachment page display full image, open the post-template.php file in /wp-include/ folder using the text editor that comes with your hosting file manager. This is the same WordPress core file I mentioned in my previous post. The folder can be found in the folder where you installed WordPress.

Then, look for the following code:

$p .= wp_get_attachment_link(0, 'medium', false);

Replace the medium with full. Then save the file.

Then, refresh the attachment page and you will see that it's now displaying the full image.

One final tip: if you want the attachment page to display the full size image and this image is not a hyperlink, you can implement this tweak together with the one I discussed in my previous post about removing the link in image in the attachment page. This should be very easy since you only need to edit one core WordPress file: post-template.php.

Important notes:

  • The post-template.php is a core WordPress file and not part of the template. Upgrading your WordPress to another version will cause this file to be replaced and you need to implement this tweak again.
  • This tweak was tested on WordPress 2.7.1 and 2.9.2. It is likely to work in all near versions and all versions in between.
  • Aside from full, you can also replace medium with thumbnail and large, which also corresponds to their settings in Settings » Media.
  • This tweak allows you to display the image in its actual size. Be sure that all the image you upload will fit in the content area of your theme i.e., not too big to ruin the look and feel of your web page.

Posted by Greten on June 9, 2010 under WordPress

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google
  • StumbleUpon
  • Technorati

Related Posts

You might also be interested (randomly generated):

Read Comments

  1. Posted by Blain Reinkensmeyer on 08.03.10 2:50 am

    You have no idea how long I have been looking for this simple fix for my blog… In fact, just so you know it has been over a YEAR. Ive had several coders look at this and they messed with the theme thinking it was one of the theme files. Yet it was so simple as a WordPress file.

    THANK YOU for posting this fix!!!!!!!!!!!!!!!!

  2. Posted by Greten on 08.08.10 4:39 am

    You’re welcome =)

  3. Posted by Ross on 05.31.11 7:57 am

    In fact, this can easily be “fixed” with a theme file. And that should also be the preferred way, rather than messing with core files that get overwritten at each update.

    All you need to do is create a file image.php according to the template hierarchy:
    http://codex.wordpress.org/images/1/18/Template_Hierarchy.png
    You can do that by simply copying single.php which most likely is currently used to render the attachment page. Now edit that copy to have full control over how you would like to display your images. To accomplish both no link and full-size images, insert
    echo wp_get_attachment_image(get_the_ID(), ‘full’);
    wherever you want it to appear.

  4. Posted by Greten on 06.25.11 7:29 am

    Hi Ross

    A solution that modifies only the theme files and not the core files is always much better and I am constantly looking for solutions to replace those that involved modification of core files.

    I checked the template hierarchy but there is no image.php in it.

Post Comments





Comment Rules and Reminders

  • The links to the commentator's e-mail do not have nofollow tag. However, I will be very strict in approving comments.
  • When you comment, please say something that indicates that you indeed read my post. If your comment is a general statement that can fit to any blog post about any topic, it will be regarded as spam.
  • What you write in the name field may include keywords to your website provided that (1) it's only up to four words long and (2) at least one of these four words is your first name or nickname. I rather reply to Bob or to Joe Smith than to Online Marketing Tips.
  • Please double check your comment before clicking the "Post" button. Once you clicked it, there will be no way for you to edit your comment.
  • Fields marked with asterisks (*) are required. Your email will never be displayed in public.