Ticket #23617: 23617.1.diff
File 23617.1.diff, 3.0 KB (added by , 12 years ago) |
---|
-
wp-content/themes/twentyten/functions.php
514 514 ); 515 515 } 516 516 endif; 517 518 /** 519 * Finds galleries for a post, then counts the total number of images and finds 520 * the first image in the gallery, for display on index/archive/search views. 521 * 522 * @uses get_post_galleries() first, if available. Falls back to shortcode parsing, 523 * then as last option uses a get_posts() call. 524 * 525 * @since Twenty Ten 1.6. 526 * 527 * @return mixed Boolean on empty result, array of image IDs if successful. 528 */ 529 function twentyten_get_gallery_images() { 530 $images = false; 531 532 if ( function_exists( 'get_post_gallery_images' ) ) { 533 $galleries = get_post_galleries(); 534 if ( isset( $galleries[0]['ids'] ) ) 535 $images = explode( ',', $galleries[0]['ids'] ); 536 } else { 537 $pattern = get_shortcode_regex(); 538 preg_match( "/$pattern/s", get_the_content(), $match ); 539 $atts = shortcode_parse_atts( $match[3] ); 540 if ( isset( $atts['ids'] ) ) 541 $images = explode( ',', $atts['ids'] ); 542 } 543 544 if ( ! $images ) { 545 $images = get_posts( array( 546 'fields' => 'ids', 547 'numberposts' => 999, 548 'order' => 'ASC', 549 'orderby' => 'menu_order', 550 'post_mime_type' => 'image', 551 'post_parent' => get_the_ID(), 552 'post_type' => 'attachment', 553 ) ); 554 } 555 556 return $images; 557 } -
wp-content/themes/twentyten/loop.php
70 70 <?php the_content(); ?> 71 71 <?php else : ?> 72 72 <?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 $images = twentyten_get_gallery_images(); 74 74 if ( $images ) : 75 75 $total_images = count( $images ); 76 76 $image = array_shift( $images ); 77 $image_img_tag = wp_get_attachment_image( $image->ID, 'thumbnail' );78 77 ?> 79 78 <div class="gallery-thumb"> 80 <a class="size-thumbnail" href="<?php the_permalink(); ?>"><?php echo $image_img_tag; ?></a>79 <a class="size-thumbnail" href="<?php the_permalink(); ?>"><?php echo wp_get_attachment_image( $image, 'thumbnail' ); ?></a> 81 80 </div><!-- .gallery-thumb --> 82 81 <p><em><?php printf( _n( 'This gallery contains <a %1$s>%2$s photo</a>.', 'This gallery contains <a %1$s>%2$s photos</a>.', $total_images, 'twentyten' ), 83 82 'href="' . get_permalink() . '" title="' . esc_attr( sprintf( __( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ) ) . '" rel="bookmark"', 84 83 number_format_i18n( $total_images ) 85 84 ); ?></em></p> 86 <?php endif; ?>85 <?php endif; // end twentyten_get_gallery_images() check ?> 87 86 <?php the_excerpt(); ?> 88 87 <?php endif; ?> 89 88 </div><!-- .entry-content -->