WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Gallery - Click on Image to view Next Image? How? (21 posts)

  1. kicksonfire
    Member
    Posted 5 years ago #

    When browsing through the gallery, I already have added the option for my users to click on Previous / Next Image. But what I want to do now is: I want them to be able to click the image and that will take them to the next image in the gallery. Much like facebook... Please help.

    Example: http://www.kicksonfire.com/2008/11/04/air-jordan-6-six-rings-black-dark-army-varsity-red-3/air-jordan-6-six-rings-black-dark-army-varsity-red-2-2/

    I want users to be able to click that big image to take them to the next image ! :)

  2. kicksonfire
    Member
    Posted 5 years ago #

    Is the very hard to do ? It seems like no one can help me...

  3. aka9527
    Member
    Posted 5 years ago #

    Well, you need a plugin to do it. Try the lightbox plugin for wordpress, it support single or group image show and you can find it in plugin category.

  4. kicksonfire
    Member
    Posted 5 years ago #

    The Lightbox plugin does not do what I want... i want to keep my gallery how it is now. None of that light box fancy stuff...

  5. kicksonfire
    Member
    Posted 5 years ago #

    Can someone PLEASE help :( I just want to make ONE image clickable so users could go to the next image in the gallery.. how hard can that be?!!

  6. OZtwo
    Member
    Posted 5 years ago #

    I can't help you, but maybe you can help me. What did you use to cycle through the images in the gallery??

  7. kicksonfire
    Member
    Posted 5 years ago #

    You have to create a image.php file within your theme. You can use the default theme and use that one...

    CAN someone HELP ME :(?

  8. yoshi
    Member
    Posted 5 years ago #

    <?php
    // code copied from adjacent_image_link() in wp-include/media.php
    $attachments = array_values(get_children( array('post_parent' => $post->post_parent, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID') ));
    foreach ( $attachments as $k => $attachment )
      if ( $attachment->ID == $post->ID )
        break;
    
    $next_url =  isset($attachments[$k+1]) ? get_permalink($attachments[$k+1]->ID) : get_permalink($attachments[0]->ID);
    ?>
    
    <p class="attachment"><a href="<?php echo $next_url; ?>"><?php echo wp_get_attachment_image( $post->ID, 'medium' ); ?></a></p>

    This will do.

  9. kicksonfire
    Member
    Posted 5 years ago #

    Works!!!!!! Thank you so much Yoshi. You have solved all my problems! You are the best!

  10. Tarmu
    Member
    Posted 5 years ago #

    Where do I have to place that code?

  11. kjagen
    Member
    Posted 5 years ago #

    How did you make those dropdownmenues? And the menu above??

  12. Tarmu
    Member
    Posted 5 years ago #

    No one?

  13. jtonline
    Member
    Posted 5 years ago #

    Where do I have to place that code?

    It's a while since I worked on my albums code, but if I remember correctly, yoshi's code replaced the line:

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

    in the image.php file of the default WordPress theme.

    Work on a copy of the image.php file so that you have the original to go back to if things go wrong as you experiment with new album designs.

  14. Tarmu
    Member
    Posted 5 years ago #

    Ok, thanks jtonline :) That works great.

    1 Thing left.. I'm looking for a code / widget that shows a random image from all wordpress galleries and also links to the generated image.

  15. Tarmu
    Member
    Posted 5 years ago #

    @jtonline:

    When you post an album, do you make 2 different posts? Because at the album index you have a thumbnail with description. After clicking the image gallery is different and the thumbnail isn't in the post anymore :/

  16. jtonline
    Member
    Posted 5 years ago #

    ...at the album index you have a thumbnail with description. After clicking the image gallery is different and the thumbnail isn't in the post anymore...

    Erm - yes it is :-)

    My index for all available albums lists each with a heading, a photo, a description, and a note of the number of photos the album contains. This index is just a Category Template that I created to display my 'Photos' category.

    If you click a photo or album name in the album index, you are taken to the post which contains thumbnails of all the album photos. The photo that was used in the album index is included, it's always the last one in the post and is the standard way WordPress works.

    I just use several posts (one for each photo album). Each post has a gallery included in it. Each post is allocated to a 'Photos' category. There is a category template file for the 'Photos' category so that the list of albums looks different from a list of posts from any other category in the blog.

    It doesn't get much more complicated than that for my albums.

  17. Tarmu
    Member
    Posted 5 years ago #

    Ok, I kind of sorted it out now :)

    I did it a little bit different. I created a category template like you did and showing the exterp instead of the content. So I can choose my thumbnail to show as a cover, when clicking on it it will take you to the gallerie index. Works great :D Thanks a lot!

    One last thing I want is a nice random image plugin (widget) in my sidebar witch will display a few random pictures from posts in the gallery category. But I see you are not using this. But ma.tt has it working in the sidebar.

  18. jtonline
    Member
    Posted 5 years ago #

    I don't know whether Matt is using a Plugin Widget, and if so which one.

    Have you searched the WordPress Plugins Directory? Perhaps this Widget would achieve the result you're after:

    http://wordpress.org/extend/plugins/gallery-widget/

  19. Tarmu
    Member
    Posted 5 years ago #

    Thanks jtonline, seems that that plugin is updated 4 days ago :D and works superb now!

    My site is going to be online soon.. :P

  20. eckert
    Member
    Posted 5 years ago #

    yoshi,
    thanks a million, I've been trying to do something like this for a long time and it worked perfectly.

    http://yntmedia.com/specialsections/?page_id=338

  21. hanchy
    Member
    Posted 5 years ago #

    Hi I'm trying to also do this and I can't work out how to put it in my wordpress account.
    I can't edit the php (I'm on wordpress.org) and I can't seem to find that widget to add.
    Can anyone advise how I can get my pictures to go to the next one when you click, like in facebook, in a wordpress.org blog?
    Thanks
    Hannah

Topic Closed

This topic has been closed to new replies.

About this Topic