Make WordPress Core

Ticket #22907: 22907.1.diff

File 22907.1.diff, 1.6 KB (added by obenland, 12 years ago)
  • wp-content/themes/twentyeleven/content-gallery.php

     
    3333
    3434                        <?php else : ?>
    3535                                <?php
    36                                         $images = get_children( array( 'post_parent' => $post->ID, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => 'menu_order', 'order' => 'ASC', 'numberposts' => 999 ) );
     36                                        if ( function_exists( 'get_post_gallery_images' ) ) :
     37                                                $galleries = get_post_galleries();
     38                                                $images = isset( $galleries[0]['ids'] ) ? explode( ',', $galleries[0]['ids'] ) : false;
     39                                        else :
     40                                                $pattern = get_shortcode_regex();
     41                                                preg_match( "/$pattern/s", get_the_content(), $match );
     42                                                $atts = shortcode_parse_atts( $match[3] );
     43                                                $images = isset( $atts['ids'] ) ? explode( ',', $atts['ids'] ) : false;
     44
     45                                                if ( ! $images ) :
     46                                                        $images = get_posts( array(
     47                                                                'fields'         => 'ids',
     48                                                                'numberposts'    => 999,
     49                                                                'order'          => 'ASC',
     50                                                                'orderby'        => 'menu_order',
     51                                                                'post_mime_type' => 'image',
     52                                                                'post_parent'    => $post->ID,
     53                                                                'post_type'      => 'attachment',
     54                                                        ) );
     55                                                endif;
     56                                        endif;
     57
    3758                                        if ( $images ) :
    3859                                                $total_images = count( $images );
    3960                                                $image = array_shift( $images );
    40                                                 $image_img_tag = wp_get_attachment_image( $image->ID, 'thumbnail' );
     61                                                $image_img_tag = wp_get_attachment_image( $image, 'thumbnail' );
    4162                                ?>
    4263
    4364                                <figure class="gallery-thumb">