How to Universally Show the Featured Image in the Buddypress Activity Excerpt
12 Dec 2012 21:19
I came across this problem while I was coding one of my Buddypress installs. One of my installs is completely custom PHP code and I had a situation where the featured image would not show up in the activity stream associated with a blog post.
This Literally took me a year to find/mess with and code the official thing. This code will 100% get the featured image in the specific post id to show up in the associated Buddypress Activity Stream Item's excerpt/content.
Place the Following code in your functions.php file and this will work universally:
// Here is the fix function icondeposit_bp_activity_entry_meta() { if ( bp_get_activity_object_name() == 'blogs' && bp_get_activity_type() == 'new_blog_post' ) {?> global $wpdb, $post, $bp; $theimg = wp_get_attachment_image_src( get_post_thumbnail_id( bp_get_activity_secondary_item_id() ) ); <img src=" echo $theimg[0]; " > } } add_action('bp_activity_excerpt_append_text', 'icondeposit_bp_activity_entry_meta');
Just like my freebie posts, you are required to link back to this site any time you use this code.
update: since the latest Buddypress 1.7 update this code will not work unless you manually edit it.
View the Demo:
Original URL: http://www.icondeposit.com/code:4
License Info: Creative Commons Attribution 3.0
Hello, i used your code, and it worked like a charm.
However, i would like to display the featured image at a certain size, cropped, like i did here, for featured in single blog post
Is there any way tomake the featured image in activity stream to be displayed using the 'home_top' size?
Thank you!
This worked! Thanks for sharing. Any idea how you would link the image to the post? i.e from the activity stream, user clicks on the image, then redirects to the post?