Make WordPress Core

Ticket #21082: 21082.2.diff

File 21082.2.diff, 1.7 KB (added by MikeHansenMe, 11 years ago)
  • wp-includes/media.php

     
    748748        $itemwidth = $columns > 0 ? floor(100/$columns) : 100;
    749749        $float = is_rtl() ? 'right' : 'left';
    750750
    751         $selector = "gallery-{$instance}";
     751        $selector = "gallery-{$id}-{$instance}";
    752752
    753753        $gallery_style = $gallery_div = '';
    754         if ( apply_filters( 'use_default_gallery_style', true ) )
     754       
     755        if ( apply_filters( 'use_default_gallery_style', true ) ) {
     756
    755757                $gallery_style = "
    756758                <style type='text/css'>
    757                         #{$selector} {
     759                        #{$selector} .gallery-item {
     760                                width: {$itemwidth}%;
     761                        }
     762                </style>
     763                <!-- see gallery_shortcode() in wp-includes/media.php -->";
     764
     765                //check if this is the first instance and add general styles
     766                if( 1 == $instance ) {
     767                        $general_gallery_style = "
     768                <style type='text/css'>
     769                        .gallery {
    758770                                margin: auto;
    759771                        }
    760                         #{$selector} .gallery-item {
     772                        .gallery .gallery-item {
    761773                                float: {$float};
    762774                                margin-top: 10px;
    763775                                text-align: center;
    764                                 width: {$itemwidth}%;
    765776                        }
    766                         #{$selector} img {
     777                        .gallery img {
    767778                                border: 2px solid #cfcfcf;
    768779                        }
    769                         #{$selector} .gallery-caption {
     780                        .gallery .gallery-caption {
    770781                                margin-left: 0;
    771782                        }
    772                 </style>
    773                 <!-- see gallery_shortcode() in wp-includes/media.php -->";
     783                </style>";
     784                        $gallery_style .= $general_gallery_style;
     785                }
     786        }
     787
    774788        $size_class = sanitize_html_class( $size );
    775789        $gallery_div = "<div id='$selector' class='gallery galleryid-{$id} gallery-columns-{$columns} gallery-size-{$size_class}'>";
    776790        $output = apply_filters( 'gallery_style', $gallery_style . "\n\t\t" . $gallery_div );