Support » Fixing WordPress » Full Size Image on Attachment Page for Galleries

  • Resolved walkinman



    I’m setting up a site and trying to configure the best options for galleries. I’ve decided (almost certainly) I don’t want any kind of Lightbox effect, but would rather a gallery of thumbnails that open to attachment pages. The Default WP gallery works great for this, with Twenty Twelve theme – almost.

    I can’t configure the theme so that the attachment page displays a full size image. I’ve added this code

    function prepend_attachment($content) {
    	$post = get_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, 'large', false);
    	$p .= '</p>';
    	$p = apply_filters('prepend_attachment', $p);
    	return "$p\n$content";

    or similar, substituting “full” for “large”, etc .. I’ve tried adding it to the wp-includes/post-template.php file, the theme functions.php file, and got nowhere.

    The closest I have is right now, when I make a new gallery, and preview it, everything works correctly. The attachment page opens up, the image is display full size, and centered .. when I publish the gallery page, and everything goes live, the attachment pages go back to displaying a smaller image file, and it’s not centered but aligned to the left.

    an example gallery is here:

    Those images in the attachment page should be 750px wide .. the vertical ones do display at the correct size, but again, aren’t centered on the page.

    Any help here I’d be super grateful.

    Thanks so much

Viewing 4 replies - 1 through 4 (of 4 total)
  • OK – it works correctly when I switch to Twenty Eleven. But even if I make a new gallery in Twenty Twelve, that theme seems to display the attachment page differently. If someone can point me in the right direction their help is much appreciated.


    OK – this is really weird. When I make a new page, and create a gallery, everything works fine when I preview the gallery and attached pages. In all 3 of the default wp-themes. Using Twenty Twelve, when I then publish the page, those attachment pages no longer display correctly. They show a smaller image file, and they don’t center the image .. it’s as if they try to display the page as including a sidebar (with no content in the sidebar) rather than a full page. Hence the full size images, 750px, don’t fit. I guess that’s what’s happening.

    They work correctly in Twenty Ten and Twenty Eleven. I notice Twenty Twelve doesn’t have an attachment.php file, like the other 2 both do.

    I’ve re-uploaded a clean theme and some of the files I might have changed in WP, like post-template.php. Nothing seems to fix it. As soon as I go from previewing an unpublished page, where everything works fine, to viewing a published page, the attached pages don’t work correctly. I’m sure it’s something simple, but I’ve no idea quite what it might be.


    OK – the latest is this .. in case anyone finds it useful

    this post seems to address the issue .. at least it did for me.

    Add this code to the theme’s .css file

    .attachment .site-content {
        margin-left: auto;
        width: 100%;

    I suspect that was the error .. it seems to have resolved it for me anyway.

    Marking solved.

    Thank you! You are my hero!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Full Size Image on Attachment Page for Galleries’ is closed to new replies.