From 1de8d8034629b412360cbd3024f4f1f3eb391f58 Mon Sep 17 00:00:00 2001 From: Andrew Ozz 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: https://develop.svn.wordpress.org/trunk@11339 602fd350-edb4-49c9-b593-d223f7449a82 --- 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', " -