Make WordPress Core

Ticket #7678: 7678_combined.diff

File 7678_combined.diff, 1.3 KB (added by jamescollins, 17 years ago)

uses unique css id for styling, and a galleryid-x class

  • wp-includes/media.php

     
    610610 */
    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.
    615618        $output = apply_filters('post_gallery', '', $attr);
     
    651654        $captiontag = tag_escape($captiontag);
    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;
    676681        foreach ( $attachments as $id => $attachment ) {