Ticket #22907: 22907.diff

File 22907.diff, 1.4 KB (added by obenland, 5 months 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                                        $pattern = get_shortcode_regex(); 
     37                                        preg_match( "/$pattern/s", get_the_content(), $match ); 
     38                                        $atts = shortcode_parse_atts( $match[3] ); 
     39                                        $images = isset( $atts['ids'] ) ? explode( ',', $atts['ids'] ) : false; 
     40 
     41                                        if ( ! $images ) : 
     42                                                $images = get_posts( array( 
     43                                                        'post_parent'    => $post->ID, 
     44                                                        'fields'         => 'ids', 
     45                                                        'post_type'      => 'attachment', 
     46                                                        'post_mime_type' => 'image', 
     47                                                        'orderby'        => 'menu_order', 
     48                                                        'order'          => 'ASC', 
     49                                                        'numberposts'    => 999 
     50                                                ) ); 
     51                                        endif; 
     52 
    3753                                        if ( $images ) : 
    3854                                                $total_images = count( $images ); 
    3955                                                $image = array_shift( $images ); 
    40                                                 $image_img_tag = wp_get_attachment_image( $image->ID, 'thumbnail' ); 
     56                                                $image_img_tag = wp_get_attachment_image( $image, 'thumbnail' ); 
    4157                                ?> 
    4258 
    4359                                <figure class="gallery-thumb">