#5060 closed enhancement (fixed)
Add $args parameter to bp_activity_thumbnail_content_images()
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 1.8 | Priority: | normal |
| Severity: | normal | Version: | |
| Component: | Activity | Keywords: | has-patch |
| Cc: |
Description
It would be very nice if the args from the bp_blogs_record_activity() request were passed into the bp_activity_thumbnail_content_images() function and filter.
This would give developers the opportunity to easily override the prepended BuddyPress (first img found in post) thumbnail.
Here's a use case:
function at_add_custom_thumbnail( $content, $matches, $args ) {
// we don't want images for blog comments
if ( 'new_blog_comment' == $args['type'] )
return $content;
$post_id = $args['secondary_item_id'];
$attachments = get_posts( array( 'post_type' => 'attachment', 'numberposts' => 1, 'post_status' => null, 'order'=> 'DESC', 'post_mime_type' => 'image', 'post_parent' => $post_id ) );
// post has thumbnail so use that
if ( has_post_thumbnail( $post_id ) )
$image_url = get_the_post_thumbnail( $post_id, 'activity-stream' );
elseif ( $attachments )
$image_url = wp_get_attachment_image( $attachments[0]->ID, 'activity-stream' );
else
return $content;
$image = '<a href="' . get_permalink( $post_id ) . '">' . $image_url . '</a>';
// strip out the img bp uses & other html tags
$content = strip_tags( $content );
// prepend our thumbnail to the content
$content = $image . $content;
return $content;
}
add_filter( 'bp_activity_thumbnail_content_images', 'at_add_custom_thumbnail', 10, 3 );
Proposed patch has been attached. Thank you.
Attachments (1)
Change History (4)
Note: See
TracTickets for help on using
tickets.
Looks legit. We're into the 1.8 beta period, which generally means no new enhancement requests for this release, but this is pretty harmless.