• Resolved erikturner

    (@erikturner)


    I had a separate post running, but I think it was not straight forward because it basically consisted of me figuring out what I needed to do.

    Now I know what I need, but need some PHP help! I am using the Constructor theme, and need to create an image.php file (there is none present for this theme). I have tried using image.php files I’ve found elsewhere for other themes, but don’t know enough to be able to edit it for my purposes.

    My goal is to use the WP gallery like I normally do, with thumbnails in the posts, and link the thumbnails to the attachment page. The problem is now the attachment page features the images at medium size (why is this the default?!). I’d like it to be at full size. Currently to see full size, you’d have to click again, and then its just the image, no sidebars or headers or image titles.

    I believe this would be easy for someone who knows their way around PHP- hopefully a kind soul will have a second to help me keep from pulling my hair out.

    for reference sake here’s my page: http://www.erikturner.net/wordpress

    any post that has 150×150 thumbnails are the WP gallery which I’m referring to in this post- click on it and it only gets slightly bigger! That’s what I’m trying to fix. Thanks!!

Viewing 11 replies - 1 through 11 (of 11 total)
  • esmi

    (@esmi)

    Use the image.php file in the default them as a guide but change:

    <a href="<?php echo wp_get_attachment_url($post->ID); ?>"><?php echo wp_get_attachment_image( $post->ID, 'medium' ); ?></a>

    to:

    <?php echo wp_get_attachment_image( $post->ID, 'full' ); ?>

    Thread Starter erikturner

    (@erikturner)

    Thanks for your reply.

    I tried a similar approach before, but the problem is the sidebars are no longer present. Probably best to show by example:

    go here: http://www.erikturner.net/wordpress/?p=342

    and click on any of the small thumbnails. It does show the fullsized jpg, but it doesn’t have the sidebars there for navigation.

    Prior to having any image.php file in the current theme’s directory I guess it was using some default settings, which were good in that the sidebars were still there on the attachment page, but the size was medium. The only thing I’d like to change is the size.

    If it helps, I pasted the code I’m currently using below. I can’t even make enough sense of it to figure out which sections need to be changed to put in the sidebars.

    Thanks!!!

    [Code moderated as per the Forum Rules. Please use the pastebin]

    esmi

    (@esmi)

    I’d suggest comparing your current image.php file with your page.php file. The code in both files should be broadly similar and you should be able to use the sidebar code in page.php within image.php.

    Thread Starter erikturner

    (@erikturner)

    also just noticed that as it is now, it shows thumbnails of the previous and next pictures, which you can click to go to their attachment pages. That is actually really cool! This is close to being stellar, but I just need a way to get those thumbnails on the attachment page to be placed better (under the full sized, not overlapping text) and the sidebars.

    Thread Starter erikturner

    (@erikturner)

    The beginning of the image.php file has this:

    get_header();
    ?>
    
    	<div id="content" class="widecolumn">

    Is the class widecolumn at issue here? Is that making it display as just one single wide column? Do I need to do something like get_sidebar(); similar to get_header(); ?? I just don’t know the syntax of these things… I’m not too familiar with PHP, nor the wordpress system to know the changes needed right off…

    I have gotten the preview images to show in a better place, and got rid of some of the other text that was overlapping.

    esmi

    (@esmi)

    Is the class widecolumn at issue here?

    Almost certainly since I think you’re using some of the default theme template files. Try changing that line to:

    <div id="content" class="narrowcolumn">

    and see if that helps.

    Do I need to do something like get_sidebar();

    Yes! Check page.php to see where this is normally inserted in your template files and try to match that position in the code.

    Thread Starter erikturner

    (@erikturner)

    Rocking… this is getting very close! Thanks so much for your help. The page.php file is really complicated, but it has a whole different div at the top:

    <div id="container">

    and nothing about class or columns. I experimented with container in the image.php file but that didn’t seem to work too well. But with the narrowcolumn class it puts the images in the right spot, and space is there for the sidebars.

    I inserted the get_sidebar();, but I guess my main sidebar is the one that is normally shown on the right. I also have one on the left, what might be the syntax for the second one? It’s also just putting the sidebar on top of the images…. not recognizing that it needs to go in the right column I guess. (http://www.erikturner.net/wordpress/?attachment_id=349) Any ideas on getting the sidebar content into the right place now?

    Thanks!!

    Thread Starter erikturner

    (@erikturner)

    …oops, not sure if it matters, but the “container” is the one that sets the images in the correct spot (in the middle of three columns). So I’m using this:

    <div id="container" class="narrowcolumn">

    esmi

    (@esmi)

    The easiest way to get this right would be to start again,. Save a copy of your current image,.php file. You’ll need to refer to it. Next, make a copy of your theme’s page.php file and name this new copy “image.php”.

    Look for <?php the_content(); ?>. After that line, add the next & previous image links from your old image.php file (the <?php previous_image_link(); ?> & <?php next_image_link();?> code blocks).

    Now see how that works. I don’t “know” your theme but, in theory, this should give you the right structure pretty much straight away.

    Thread Starter erikturner

    (@erikturner)

    MONEY! It is working great now. Thanks for the tip about comparing to page.php, that was the key, for me at least! What can a PHP-clueless person do to help you with something? Normally I’d buy a fellow a beer or something for this much help.

    esmi

    (@esmi)

    Glad to help. Just mark this as resolved by way of thanks. 🙂

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Image.php to show “full” instead of “medium” for WP Gallery’ is closed to new replies.