Make WordPress Core

Changeset 11339


Ignore:
Timestamp:
05/15/2009 08:52:04 AM (16 years ago)
Author:
azaozz
Message:

Support more than one gallery on the same page, props jamescollins, fixes #7678

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/media.php

    r11336 r11339  
    611611function gallery_shortcode($attr) {
    612612    global $post;
     613   
     614    static $instance = 0;
     615    $instance++;
    613616
    614617    // Allow plugins/themes to override the default gallery template.
     
    643646    if ( is_feed() ) {
    644647        $output = "\n";
    645         foreach ( $attachments as $id => $attachment )
    646             $output .= wp_get_attachment_link($id, $size, true) . "\n";
     648        foreach ( $attachments as $att_id => $attachment )
     649            $output .= wp_get_attachment_link($att_id, $size, true) . "\n";
    647650        return $output;
    648651    }
     
    652655    $columns = intval($columns);
    653656    $itemwidth = $columns > 0 ? floor(100/$columns) : 100;
     657   
     658    $selector = "gallery-{$instance}";
    654659
    655660    $output = apply_filters('gallery_style', "
    656661        <style type='text/css'>
    657             .gallery {
     662            #{$selector} {
    658663                margin: auto;
    659664            }
    660             .gallery-item {
     665            #{$selector} .gallery-item {
    661666                float: left;
    662667                margin-top: 10px;
    663668                text-align: center;
    664669                width: {$itemwidth}%;           }
    665             .gallery img {
     670            #{$selector} img {
    666671                border: 2px solid #cfcfcf;
    667672            }
    668             .gallery-caption {
     673            #{$selector} .gallery-caption {
    669674                margin-left: 0;
    670675            }
    671676        </style>
    672677        <!-- see gallery_shortcode() in wp-includes/media.php -->
    673         <div class='gallery'>");
     678        <div id='$selector' class='gallery galleryid-{$id}'>");
    674679
    675680    $i = 0;
Note: See TracChangeset for help on using the changeset viewer.