| 631 | | // Add URLs to any Featured Image this post might have. |
| 632 | | if ( ! empty( $paged_blogs[$i]->latest_post ) && has_post_thumbnail( $paged_blogs[$i]->latest_post->ID ) ) { |
| 633 | | |
| 634 | | // Grab 4 sizes of the image. Thumbnail. |
| 635 | | $image = wp_get_attachment_image_src( get_post_thumbnail_id( $paged_blogs[$i]->latest_post->ID ), 'thumbnail', false ); |
| 636 | | if ( ! empty( $image ) ) |
| 637 | | $images['thumbnail'] = $image[0]; |
| 638 | | |
| 639 | | // Medium. |
| 640 | | $image = wp_get_attachment_image_src( get_post_thumbnail_id( $paged_blogs[$i]->latest_post->ID ), 'medium', false ); |
| 641 | | if ( ! empty( $image ) ) |
| 642 | | $images['medium'] = $image[0]; |
| 643 | | |
| 644 | | // Large. |
| 645 | | $image = wp_get_attachment_image_src( get_post_thumbnail_id( $paged_blogs[$i]->latest_post->ID ), 'large', false ); |
| 646 | | if ( ! empty( $image ) ) |
| 647 | | $images['large'] = $image[0]; |
| 648 | | |
| 649 | | // Post thumbnail. |
| 650 | | $image = wp_get_attachment_image_src( get_post_thumbnail_id( $paged_blogs[$i]->latest_post->ID ), 'post-thumbnail', false ); |
| 651 | | if ( ! empty( $image ) ) |
| 652 | | $images['post-thumbnail'] = $image[0]; |
| 653 | | |
| 654 | | // Add the images to the latest_post object. |
| 655 | | $paged_blogs[$i]->latest_post->images = $images; |
| | 630 | /** |
| | 631 | * Filters whether to fetch Featured Images for the Sites directory. |
| | 632 | * |
| | 633 | * @since 11.0.0 |
| | 634 | * |
| | 635 | * @param bool $fetch_featured_images Defaults to true. |
| | 636 | * @param int $blog_id ID of the current blog whose extras are being generated. |
| | 637 | */ |
| | 638 | if ( apply_filters( 'bp_blogs_fetch_latest_post_thumbnails', true, $paged_blogs[ $i ]->blog_id ) ) { |
| | 639 | $images = array(); |
| | 640 | |
| | 641 | switch_to_blog( $paged_blogs[ $i ]->blog_id ); |
| | 642 | |
| | 643 | // Add URLs to any Featured Image this post might have. |
| | 644 | if ( ! empty( $paged_blogs[$i]->latest_post ) && has_post_thumbnail( $paged_blogs[$i]->latest_post->ID ) ) { |
| | 645 | |
| | 646 | // Grab 4 sizes of the image. Thumbnail. |
| | 647 | $image = wp_get_attachment_image_src( get_post_thumbnail_id( $paged_blogs[$i]->latest_post->ID ), 'thumbnail', false ); |
| | 648 | if ( ! empty( $image ) ) |
| | 649 | $images['thumbnail'] = $image[0]; |
| | 650 | |
| | 651 | // Medium. |
| | 652 | $image = wp_get_attachment_image_src( get_post_thumbnail_id( $paged_blogs[$i]->latest_post->ID ), 'medium', false ); |
| | 653 | if ( ! empty( $image ) ) |
| | 654 | $images['medium'] = $image[0]; |
| | 655 | |
| | 656 | // Large. |
| | 657 | $image = wp_get_attachment_image_src( get_post_thumbnail_id( $paged_blogs[$i]->latest_post->ID ), 'large', false ); |
| | 658 | if ( ! empty( $image ) ) |
| | 659 | $images['large'] = $image[0]; |
| | 660 | |
| | 661 | // Post thumbnail. |
| | 662 | $image = wp_get_attachment_image_src( get_post_thumbnail_id( $paged_blogs[$i]->latest_post->ID ), 'post-thumbnail', false ); |
| | 663 | if ( ! empty( $image ) ) |
| | 664 | $images['post-thumbnail'] = $image[0]; |
| | 665 | |
| | 666 | // Add the images to the latest_post object. |
| | 667 | $paged_blogs[$i]->latest_post->images = $images; |
| | 668 | } |
| | 669 | |
| | 670 | restore_current_blog(); |