From 77c8335821b8c3c7b02195c45029734786566e19 Mon Sep 17 00:00:00 2001 From: matt Date: Tue, 11 Mar 2008 00:09:14 +0000 Subject: [PATCH] Better media attachment template. See #5911. Hat tip: andy. git-svn-id: http://svn.automattic.com/wordpress/trunk@7222 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- .../default/{attachment.php => image.php} | 20 ++++++++-------- wp-includes/media.php | 23 +++++++++++++++++++ 2 files changed, 32 insertions(+), 11 deletions(-) rename wp-content/themes/default/{attachment.php => image.php} (74%) 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); +} + ?>