Adding a comment and like counter to gallery thumbnails

I'm currently using Buddypress Media with my Buddypress installation. What I'm looking to do is add the count for the number of comments and likes underneath each gallery thumbnail. I read in a thread with similar issues the best way to go about it is to use wordpress's comment count function http://codex.wordpress.org/Function_Reference/wp_count_comments with the rtmedia_media_id($rtmedia_id) function, but trying to combined the two hasn't worked. I'm also looking for the correct functions to show the number of likes a images has.

I greatly appreciate any help. Thanks in advance. :)

@rao - You can use the 'rtmedia_after_item' action or override the media-gallery-item.php template for that ( http://rtcamp.com/rtmedia/docs/developer/templating-system/ ).

You would need to add the following on that action or template.

  • For comment count ( http://codex.wordpress.org/Function_Reference/wp_count_comments )

    $comment_counts = wp_comment_count( rtmedia_media_id() );

Check the documentation for that as you will get an object containing the necessary details.

  • For like count, there will be a function available in the next release get_rtmedia_like(), which can be used; for now you can use the following
$mediamodel = new RTMediaModel();  
    $actions = $mediamodel->get( array( 'id' => rtmedia_id() ) );  
    if ( isset( $actions[ 0 ]->likes ) ){  
        $actions = intval($actions[ 0 ]->likes);  
    } else {   
        $actions = 0;  
    }   
    echo $actions;