From 8fcacb951d64fc7794b6c1f9513a41eeeb87e515 Mon Sep 17 00:00:00 2001 From: azaozz Date: Fri, 15 May 2009 08:52:04 +0000 Subject: [PATCH] Support more than one gallery on the same page, props jamescollins, fixes #7678 git-svn-id: http://svn.automattic.com/wordpress/trunk@11339 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/media.php | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/wp-includes/media.php b/wp-includes/media.php index 917163d9a1..ce1e821ed4 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -610,6 +610,9 @@ add_shortcode('gallery', 'gallery_shortcode'); */ function gallery_shortcode($attr) { global $post; + + static $instance = 0; + $instance++; // Allow plugins/themes to override the default gallery template. $output = apply_filters('post_gallery', '', $attr); @@ -642,8 +645,8 @@ function gallery_shortcode($attr) { if ( is_feed() ) { $output = "\n"; - foreach ( $attachments as $id => $attachment ) - $output .= wp_get_attachment_link($id, $size, true) . "\n"; + foreach ( $attachments as $att_id => $attachment ) + $output .= wp_get_attachment_link($att_id, $size, true) . "\n"; return $output; } @@ -651,26 +654,28 @@ function gallery_shortcode($attr) { $captiontag = tag_escape($captiontag); $columns = intval($columns); $itemwidth = $columns > 0 ? floor(100/$columns) : 100; + + $selector = "gallery-{$instance}"; $output = apply_filters('gallery_style', " -