Make WordPress Core

Ticket #23617: 23617.diff

File 23617.diff, 1.7 KB (added by obenland, 12 years ago)
  • wp-content/themes/twentyten/loop.php

     
    7070                                <?php the_content(); ?>
    7171<?php else : ?>
    7272                                <?php
    73                                         $images = get_children( array( 'post_parent' => $post->ID, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => 'menu_order', 'order' => 'ASC', 'numberposts' => 999 ) );
     73                                        if ( function_exists( 'get_post_gallery_images' ) ) :
     74                                                $galleries = get_post_galleries();
     75                                                $images = isset( $galleries[0]['ids'] ) ? explode( ',', $galleries[0]['ids'] ) : false;
     76                                        else :
     77                                                $pattern = get_shortcode_regex();
     78                                                preg_match( "/$pattern/s", get_the_content(), $match );
     79                                                $atts = shortcode_parse_atts( $match[3] );
     80                                                $images = isset( $atts['ids'] ) ? explode( ',', $atts['ids'] ) : false;
     81
     82                                                if ( ! $images ) :
     83                                                        $images = get_posts( array(
     84                                                                'fields'         => 'ids',
     85                                                                'numberposts'    => 999,
     86                                                                'order'          => 'ASC',
     87                                                                'orderby'        => 'menu_order',
     88                                                                'post_mime_type' => 'image',
     89                                                                'post_parent'    => $post->ID,
     90                                                                'post_type'      => 'attachment',
     91                                                        ) );
     92                                                endif;
     93                                        endif;
     94
    7495                                        if ( $images ) :
    7596                                                $total_images = count( $images );
    7697                                                $image = array_shift( $images );
    77                                                 $image_img_tag = wp_get_attachment_image( $image->ID, 'thumbnail' );
     98                                                $image_img_tag = wp_get_attachment_image( $image, 'thumbnail' );
    7899                                ?>
    79100                                                <div class="gallery-thumb">
    80101                                                        <a class="size-thumbnail" href="<?php the_permalink(); ?>"><?php echo $image_img_tag; ?></a>