| | 341 | function previous_image_link() { |
|---|
| | 342 | adjacent_image_link(true); |
|---|
| | 343 | } |
|---|
| | 344 | |
|---|
| | 345 | function next_image_link() { |
|---|
| | 346 | adjacent_image_link(false); |
|---|
| | 347 | } |
|---|
| | 348 | |
|---|
| | 349 | function adjacent_image_link($prev = true) { |
|---|
| | 350 | global $post; |
|---|
| | 351 | $post = get_post($post); |
|---|
| | 352 | $attachments = array_values(get_children("post_parent=$post->post_parent&post_type=attachment&post_mime_type=image&orderby=\"menu_order ASC, ID ASC\"")); |
|---|
| | 353 | |
|---|
| | 354 | foreach ( $attachments as $k => $attachment ) |
|---|
| | 355 | if ( $attachment->ID == $post->ID ) |
|---|
| | 356 | break; |
|---|
| | 357 | |
|---|
| | 358 | $k = $prev ? $k - 1 : $k + 1; |
|---|
| | 359 | |
|---|
| | 360 | if ( isset($attachments[$k]) ) |
|---|
| | 361 | echo get_the_attachment_link($attachments[$k]->ID, true, array(128, 96), true); |
|---|
| | 362 | } |
|---|
| | 363 | |
|---|