[buddypress-trac] [BuddyPress] #5060: Add $args parameter to bp_activity_thumbnail_content_images()
buddypress-trac
noreply at wordpress.org
Tue Jun 18 16:03:36 UTC 2013
#5060: Add $args parameter to bp_activity_thumbnail_content_images()
-------------------------+-----------------------------
Reporter: dcowgill | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Activity | Version:
Severity: normal | Keywords: has-patch
-------------------------+-----------------------------
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.
--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/5060>
BuddyPress <http://buddypress.org/>
BuddyPress
More information about the buddypress-trac
mailing list