WordPress.org

Ready to get started?Download WordPress

Forums

Gallery Navigation (34 posts)

  1. Laura
    Member
    Posted 6 years ago #

    I've been working with the new built in gallery feature and I'm not getting the gallery navigation (by that, I mean the 'next' and 'previous' thumbnails seen on Matt's installation and in his screencast). Is there something special that needs to happen in the template for that to happen? A new set of tags to include or somesuch? And I didn't see a way to do the links like Matt has (like the View Full Resolution link). I didn't see any reference to any new template tags on the page about gallery shortcodes. Is there another reference somewhere? Pointers or answers or even just vague clues would be much appreciated.

    Also, I am not able to upload more than one file at a time (as Matt showed in his screencast). That seems less about themes and more like a bug, but I thought I may as well mention it to see if it's just me or something that's across the board.

  2. tmobilon
    Member
    Posted 6 years ago #

    I'm with the very same doubt, and i'd like to know how to do all that stuff that Matt did in his Gallery.

  3. falcor200
    Member
    Posted 6 years ago #

    I also cant get the new gallery feature to work like Matts. I am able to upload more then one file at once but I would like to be able to post the one small image that opens up the gallery rather then post all the gallry images on the page.

  4. Laura
    Member
    Posted 6 years ago #

    Ok, I get the navigation thumbnails (previous/next images) when I use the Default theme included with 2.5. It didn't work with the Default theme from the previous WP version. Not sure what changed; I'll see if I can find it.

    Still can't upload more than one image at a time, though. (Firefox 2.0.0.13 or Safari 3.0.4 on OSX 10.5.2)

  5. Laura
    Member
    Posted 6 years ago #

    OooooooooKay. Found it.

    There's a new template you need to create to display your gallery images the way you want. You need to create 'image.php' and include the next-previous links there. You can look at the image.php file included with the Default theme for an example, but basically, when you include the tags below, you'll get the thumbnails.

    <div class="navigation">
       <div class="alignleft"><?php previous_image_link() ?></div>
       <div class="alignright"><?php next_image_link() ?></div>
    </div>
  6. sacredpath
    Moderator
    Posted 6 years ago #

    @mitten, thanks so much for posting that, but I have to ask MATTCO, why he hell do we have to do this?

  7. Laura
    Member
    Posted 6 years ago #

    Can't answer that, sacredpath. It does seem a little mean to make a new template available but not tell anyone about it.

    I wrote a quick blog post about it; there are more new template tags besides the ones I mentioned above.

  8. tmobilon
    Member
    Posted 6 years ago #

    I'm still trying to find out how to show the galleries like matt does at the listages, and how to show picture exif informations.

    Thanks mitten for the help!

  9. DoorFrame
    Member
    Posted 6 years ago #

    Matt's using some variant on the Asides trick:

    http://codex.wordpress.org/Adding_Asides

  10. DoorFrame
    Member
    Posted 6 years ago #

    Though, admittedly, I don't know what he's doing to pull an exemplary image from the image gallery... Hmm...

  11. DoorFrame
    Member
    Posted 6 years ago #

    Ok, if you use the Asides trick linked above, you can create a special appearance for your image gallery posts. If you put the following in, it will display the FINAL image from your gallery with a link to that image (not the gallery):

    <?php previous_image_link() ?>

    The next_image_link does not work. The next step to recreate Matt's thing would be to modify media.php to display the image without the link so we can link back to the gallery. I guess you'll have to create a new function.

    My program skills are weak, but I can read it enough to modify what already exists. This shouldn't be too hard.

  12. danw700
    Member
    Posted 6 years ago #

    hi
    just lost my post i think - i'm a newbie - started wordpress last week - saw MAT do sone picture up load & thought it would be cool. upgraded to 2,5 c3 along the way lost all my posts & passwords even in my backup somehow. then when i get to try this i'm missing 1/2 of the buttons to the job. it just wont work.
    uninstalled went back to 2.5 and i'm waiting for a solution - i did join the bets testing email BUt my box was swamped in talk about white space - the least of worries so i got off the list
    i would like to simply upload photos btw thanks for making blogging so easy cheers dan

  13. DoorFrame
    Member
    Posted 6 years ago #

    I was wrong, this line of code used in index.php:

    <?php previous_image_link() ?>

    shows the last image uploaded into a gallery (or something) not the last image uploaded into the gallery associated with a particular post. So, as you upload new images, this image will change. Not what I wanted.

    Back to the drawing board. Someone email Ma.tt.

  14. DeanoAus
    Member
    Posted 6 years ago #

    Hi All,

    I've emailed Matt... but he specifically states on his page he won't respond to requests RE software.. so.. we'll see how we go. I too am in the same boat where I want to display a "list" of galleries.

  15. DeanoAus
    Member
    Posted 6 years ago #

    Ooh, i'm having a bit of luck using http://fairyfish.net/2007/10/16/advanced-post-image-plugin/ that plugin.

    Editing some code now to see if I can get it to format what I want, but so far I have a listing of the first photo of any post with included images.. so.. going well!

  16. DeanoAus
    Member
    Posted 6 years ago #

    Yup, working for me. :)

    Using the following code echo '<a href="'.get_permalink($post->ID).'" title="'. wptexturize($post->post_title).'">'. $img .'</a> <b>'. wptexturize($post->post_title) . '</b><br /><br />';

    I was able to get it to list all posts with photos attached, display the 'first' photo of that post, then link back to that post so all photos can be displayed. :)

  17. onedeep
    Member
    Posted 6 years ago #

    I almost have it working using the stock install. My problem is that I cannot get wp_get_attachment_image to work on my index page, which means I cannot get the image to show up. I really feel if I can figure out why it won't work (or is working on image.php) then I will have it sorted.

    Once I get it worked out, I'll post my results here. Hopefully someone will solve it before me, since I am getting pretty frustrated at this point.

    Anyone know why wp_get_attachment_image would work on image.php but not index.php? I have tried passing the post ID as both a variable and the actual post number, but it refuses to work.

  18. onedeep
    Member
    Posted 6 years ago #

    Getting somewhere concerning showing the first image of a gallery but linking to the gallery vs the image itself.

    I am using a modified version of the code found on the get_posts page. This code is located in my index.php file. Code is below:

    <?php
    if(in_category(14)) {
    $args = array(
    	'post_type' => 'attachment',
    	'numberposts' => 1,
    	'order' => 'ASC',
    	'post_status' => null,
    	'post_parent' => $post->ID
    	);
    $attachments = get_posts($args);
    if ($attachments) {
    	foreach ($attachments as $attachment) {
    		$thePic = wp_get_attachment_image($attachment->ID);
    	}
    }
    ?>
    <p><a href="<?php the_permalink(); ?>"><?php echo $thePic; ?></a></p>
    <?php } else {
    the_content('Read the rest of this entry &raquo;');
    } ?>

    For reference, category 14 is my "photos" category. I can get the count by using a similar method. Code is below:

    <?php
    $args = array(
    	'post_type' => 'attachment',
    	'numberposts' => null,
    	'post_status' => null,
    	'post_parent' => $post->ID
    	);
    $attachments = get_posts($args);
    if ($attachments) {
    	$picCount = count($attachments);
    }
    ?>
    <p>There are <?php echo $picCount; ?> pictures in this gallery.</p>

    Finally, I put general information about the gallery in the excerpt tag, and use the template tag the_excerpt to display it.

    Hope this helps some folks.

  19. DoorFrame
    Member
    Posted 6 years ago #

    onedeep, good job! That works to pull the first image and properly link it to the gallery. You're a hero.

  20. DeanoAus
    Member
    Posted 6 years ago #

    So what does this code enable you to do? Have the index of your blog only show the first image of a pic, then link to the page to show them all?

    Or does it create a 'gallery' for you to show all the posts that have pics?

  21. onedeep
    Member
    Posted 6 years ago #

    If I understand your questions correctly, I believe it can be used to do both.

    If you put it in your index.php file, it shows the first picture of that post's gallery, with a link to the full post, which does show all of the pictures in that particular gallery. Your other posts will continue to show as normal.

    If you put it in your archive.php file, it will do basically the same thing, but because it is only showing from one category, it is essentially creating a gallery of galleries

    Both of these are assuming you are marking all of your gallery posts with gallery specific category.

  22. DeanoAus
    Member
    Posted 6 years ago #

    Excellent news. :)

  23. AgentGreasy
    Member
    Posted 6 years ago #

    I altered your code ever so slightly...

    <?php
    if(in_category(14)) {
    $args = array(
    	'post_type' => 'attachment',
    	'numberposts' => 1,
    	'order' => 'ASC',
    	'post_status' => null,
    	'post_parent' => $post->ID
    	);
    $attachments = get_posts($args);
    if ($attachments) {
    	foreach ($attachments as $attachment) {
    		$thePic = wp_get_attachment_image($attachment->ID);
    	}
    }
    ?>
    <p><a href="<?php the_permalink(); ?>"><?php echo $thePic; ?></a></p>
    <?php continue; } else {
    the_content('Read the rest of this entry &raquo;');
    } ?>

    If you notice, at the end of thePic, I added a continue;

    This accomplishes one thing on my blog... the post was showing up twice. Now I can go in and format this directly, and it doesn't require any truly extra work within the code other than leaving this in there.

    Interestingly enough, and I can't figure out why for sure, but when using this in theloop.php when k2 is enabled, the gallery doesn't function properly - instead it just constantly shows the single picture.

    Nevertheless...

    You have brought me a million steps closer to what I was hoping the true functionality would be with the gallery.

    Applaud and gratitude all around :)

  24. DoorFrame
    Member
    Posted 6 years ago #

    Also, if you switch ASC to DESC you can pull the last image instead of the first, or you can use it to pull two different images.

  25. AgentGreasy
    Member
    Posted 6 years ago #

    For those of you using K2... The issue is in the theme itself. Both the single.php and index.php (main site and single post) utilize the same loop in "theloop.php." Due to this, just simply adding the previously mentioned code did not properly allow for the viewing of the actual gallery page within the "single" area.

    Thus, changing :

    if(in_category(3)) {

    to:

    if(!is_single() && in_category(3)) {

    This alters the rendering of a single page in order to produce the 'normal' look as opposed to the altered look for something similar to ma.tt.

  26. ivette01
    Member
    Posted 6 years ago #

    hi :) i keep trying but i think this is way out of my league, is there any way i could have text instead of the thumbnail images in the navigation? thanks.

  27. DoorFrame
    Member
    Posted 6 years ago #

    You'd have to change wp_get_attachment_link() located in post-template.php from this:

    return "<a href='$url' title='$post_title'>$link_text</a>";

    to this:

    return "<a href='$url' title='$post_title'>$post_title</a>";

    I think. I haven't tried that myself, but it should work.

  28. DeanK
    Member
    Posted 6 years ago #

    Below the two thumbnails used for last/next navigation (in image.php), I also added:

    <p align="center">Return to the post: <a href="<?php echo get_permalink($post->post_parent); ?>" rev="attachment"><?php echo get_the_title($post->post_parent); ?></a>

    (which I basically took straight from the heading code, plus adding the "Return to the post: " wording) -- that always shows an obvious link for visitors to return to the post (without having to guess that the heading does the same thing).

    Maybe that'll help anyone else reading this page.

  29. japanwindow
    Member
    Posted 6 years ago #

    Can anyone tell me how to add "previous" and "next" text links rather than using the thumbnail navigation? (And how only show these links if there is a previous and/or next image to link to...?)

  30. Anamaria
    Member
    Posted 6 years ago #

    There are instructions here on how to replace the thumbnail navigation with text links.

Topic Closed

This topic has been closed to new replies.

About this Topic