WordPress.org

Make WordPress Core

Ticket #26623: media.php.patch

File media.php.patch, 2.2 KB (added by bradvin, 6 years ago)
  • media.php

     
    735735                'size'       => 'thumbnail',
    736736                'include'    => '',
    737737                'exclude'    => '',
    738                 'link'       => ''
     738                'link'       => '',
     739                'class'          => ''
    739740        ), $attr, 'gallery'));
    740741
    741742        $id = intval($id);
     
    804805                        /* see gallery_shortcode() in wp-includes/media.php */
    805806                </style>";
    806807        $size_class = sanitize_html_class( $size );
    807         $gallery_div = "<div id='$selector' class='gallery galleryid-{$id} gallery-columns-{$columns} gallery-size-{$size_class}'>";
    808         $output = apply_filters( 'gallery_style', $gallery_style . "\n\t\t" . $gallery_div );
    809808
     809        //allow plugins or themes to alter the gallery class
     810        $gallery_class = apply_filters( 'gallery_class', "gallery galleryid-{$id} gallery-columns-{$columns} gallery-size-{$size_class} {$class}", $selector, $attr );
     811
     812        //allow plugins or themes to alter the gallery container's opening markup. E.g. include extra attributes or even use a different tag
     813        $gallery_start = apply_filters( 'gallery_container_start', "<div id='$selector' class='$gallery_class'>", $selector, $gallery_class, $attr );
     814
     815        //allow plugins or themes to alter the default gallery inline styles
     816        $gallery_style = apply_filters( 'gallery_style', $gallery_style, $selector, $attr );
     817
     818        //allow plugins or themes to alter the gallery column separator markup
     819        $gallery_separator = apply_filters( 'gallery_column_separator', '<br style="clear: both" />', $selector, $attr );
     820
     821        //allow plugins or themes to alter the gallery container's closing markup
     822        $gallery_end = apply_filters( 'gallery_container_end', "
     823                        <br style='clear: both;' />
     824                </div>\n", $selector, $attr );
     825
     826        $output =  $gallery_style . "\n\t\t" . $gallery_start;
     827
    810828        $i = 0;
    811829        foreach ( $attachments as $id => $attachment ) {
    812830                if ( ! empty( $link ) && 'file' === $link )
     
    835853                }
    836854                $output .= "</{$itemtag}>";
    837855                if ( $columns > 0 && ++$i % $columns == 0 )
    838                         $output .= '<br style="clear: both" />';
     856                        $output .= $gallery_separator;
    839857        }
    840858
    841         $output .= "
    842                         <br style='clear: both;' />
    843                 </div>\n";
     859        $output .= $gallery_end;
    844860
    845861        return $output;
    846862}