diff --git a/wp-content/themes/default/attachment.php b/wp-content/themes/default/image.php similarity index 74% rename from wp-content/themes/default/attachment.php rename to wp-content/themes/default/image.php index 7176d1b76..d8e36fd36 100644 --- a/wp-content/themes/default/attachment.php +++ b/wp-content/themes/default/image.php @@ -4,12 +4,8 @@ -
-

post_parent); ?> »

+

post_parent); ?> »

@@ -17,14 +13,15 @@ '

Pages: ', 'after' => '

', 'next_or_number' => 'number')); ?> + +
+
+
diff --git a/wp-includes/media.php b/wp-includes/media.php index 89e99c41a..05f6b831b 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -338,4 +338,27 @@ function gallery_shortcode($attr) { return $output; } +function previous_image_link() { + adjacent_image_link(true); +} + +function next_image_link() { + adjacent_image_link(false); +} + +function adjacent_image_link($prev = true) { + global $post; + $post = get_post($post); + $attachments = array_values(get_children("post_parent=$post->post_parent&post_type=attachment&post_mime_type=image&orderby=\"menu_order ASC, ID ASC\"")); + + foreach ( $attachments as $k => $attachment ) + if ( $attachment->ID == $post->ID ) + break; + + $k = $prev ? $k - 1 : $k + 1; + + if ( isset($attachments[$k]) ) + echo get_the_attachment_link($attachments[$k]->ID, true, array(128, 96), true); +} + ?>