Changeset 23824 for trunk/wp-content/themes/twentyeleven/functions.php
- Timestamp:
- 03/27/2013 08:34:28 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-content/themes/twentyeleven/functions.php
r23792 r23824 627 627 } 628 628 add_filter( 'body_class', 'twentyeleven_body_classes' ); 629 630 /** 631 * Retrieves the IDs for images in a gallery. 632 * 633 * @uses get_post_galleries() first, if available. Falls back to shortcode parsing, 634 * then as last option uses a get_posts() call. 635 * 636 * @since Twenty Eleven 1.6. 637 * 638 * @return array List of image IDs from the post gallery. 639 */ 640 function twentyeleven_get_gallery_images() { 641 $images = array(); 642 643 if ( function_exists( 'get_post_gallery_images' ) ) { 644 $galleries = get_post_galleries(); 645 if ( isset( $galleries[0]['ids'] ) ) 646 $images = explode( ',', $galleries[0]['ids'] ); 647 } else { 648 $pattern = get_shortcode_regex(); 649 preg_match( "/$pattern/s", get_the_content(), $match ); 650 $atts = shortcode_parse_atts( $match[3] ); 651 if ( isset( $atts['ids'] ) ) 652 $images = explode( ',', $atts['ids'] ); 653 } 654 655 if ( ! $images ) { 656 $images = get_posts( array( 657 'fields' => 'ids', 658 'numberposts' => 999, 659 'order' => 'ASC', 660 'orderby' => 'menu_order', 661 'post_mime_type' => 'image', 662 'post_parent' => get_the_ID(), 663 'post_type' => 'attachment', 664 ) ); 665 } 666 667 return $images; 668 }
Note: See TracChangeset
for help on using the changeset viewer.