From 17a3b54dc0cb00c45db58197f463cc6c71e5e0d9 Mon Sep 17 00:00:00 2001 From: Matt Mullenweg Date: Tue, 11 Mar 2008 00:09:14 +0000 Subject: [PATCH] Better media attachment template. See #5911. Hat tip: andy. git-svn-id: https://develop.svn.wordpress.org/trunk@7222 602fd350-edb4-49c9-b593-d223f7449a82 --- .../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 7176d1b767..d8e36fd364 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 89e99c41af..05f6b831bd 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); +} + ?>