Changeset 23826
- Timestamp:
- 03/27/2013 08:37:34 PM (12 years ago)
- Location:
- trunk/wp-content/themes/twentyten
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-content/themes/twentyten/functions.php
r23778 r23826 515 515 } 516 516 endif; 517 518 /** 519 * Retrieves the IDs for images in a gallery. 520 * 521 * @uses get_post_galleries() first, if available. Falls back to shortcode parsing, 522 * then as last option uses a get_posts() call. 523 * 524 * @since Twenty Ten 1.6. 525 * 526 * @return array List of image IDs from the post gallery. 527 */ 528 function twentyten_get_gallery_images() { 529 $images = array(); 530 531 if ( function_exists( 'get_post_gallery_images' ) ) { 532 $galleries = get_post_galleries(); 533 if ( isset( $galleries[0]['ids'] ) ) 534 $images = explode( ',', $galleries[0]['ids'] ); 535 } else { 536 $pattern = get_shortcode_regex(); 537 preg_match( "/$pattern/s", get_the_content(), $match ); 538 $atts = shortcode_parse_atts( $match[3] ); 539 if ( isset( $atts['ids'] ) ) 540 $images = explode( ',', $atts['ids'] ); 541 } 542 543 if ( ! $images ) { 544 $images = get_posts( array( 545 'fields' => 'ids', 546 'numberposts' => 999, 547 'order' => 'ASC', 548 'orderby' => 'menu_order', 549 'post_mime_type' => 'image', 550 'post_parent' => get_the_ID(), 551 'post_type' => 'attachment', 552 ) ); 553 } 554 555 return $images; 556 } -
trunk/wp-content/themes/twentyten/loop.php
r23793 r23826 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' ), … … 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; ?>
Note: See TracChangeset
for help on using the changeset viewer.