Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show previous and next image thumbnails #1

Open
mattrude opened this issue Aug 9, 2011 · 2 comments
Open

Show previous and next image thumbnails #1

mattrude opened this issue Aug 9, 2011 · 2 comments

Comments

@mattrude
Copy link
Owner

mattrude commented Aug 9, 2011

When looking at an Image, display the next image thumbnail, and previous image thumbnail.

Example: http://mattrude.com/2011/08/summer-at-the-cabin/img_3231/

@mattrude
Copy link
Owner Author

mattrude commented Aug 9, 2011

The needed code, taken from the Milly theme:

<div class="image-navigation">
    <div class="floatright">
        <?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;
    $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') ));

    $next_url =  isset($attachments[$k+1]) ? get_permalink($attachments[$k+1]->ID) : get_permalink($attachments[0]->ID);
    $previous_url =  isset($attachments[$k-1]) ? get_permalink($attachments[$k-1]->ID) : get_permalink($attachments[0]->ID);
    if ( wp_get_attachment_image( $post->ID+1 ) != null ) { ?>
    <p class="attachment">
        <?php _e('Next Image', 'milly') ?><br />
        <a href="<?php echo $next_url; ?>"><?php echo wp_get_attachment_image( $post->ID+1, 'thumbnail' ); ?></a>
    </p>
    <?php }

    if ( wp_get_attachment_image( $post->ID-1 ) != null ) { ?>
    <p class="attachment">
        <?php _e('Previous Image', 'milly') ?><br />
        <a href="<?php echo $previous_url; ?>"><?php echo wp_get_attachment_image( $post->ID-1, 'thumbnail' ); ?></a>
    </p>
    <?php } ?>
    <div class="floatright">
        <?php edit_post_link('Edit Image'); ?>
    </div>
</div>

@ghost ghost assigned mattrude Aug 9, 2011
@mattrude
Copy link
Owner Author

mattrude commented Aug 9, 2011

Function is already in the theme, but it's broken.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant