There is no avatars on recent comments


#1

Hello,

I use rtmedia + buddypress, when I use following standard loop for recent comments then there is only a default avatar of user is displayed. Avatar is displayed when somebody publish a comment on the blog section but it doesn’t work when somebody will comment photo.

$args_comm = array( 'number' => 5, 'status' => 'approve' );
$comments = get_comments($args_comm);
foreach($comments as $comment) { 
			echo my_get_comment_excerpt($comment->comment_ID, 22);
			echo get_avatar($comment->comment_author_email, 30);

					echo $comment->comment_author;
					echo get_comment_link($comment->comment_ID);
									$post_title = get_the_title($comment->comment_post_ID);
										if(strlen($post_title)>48){
											$post_title = mb_substr($post_title, 0, 40, 'utf-8');
											$post_title = $post_title . '...';
										}
									echo $post_title;
}

#2

Hi @Mariusx,

Showing avatars in media comments is little different.

You need to use function rtmedia_author_profile_pic and pass comment’s author id into this function: https://github.com/rtMediaWP/rtMedia/blob/master/app/main/controllers/template/rtmedia-functions.php?utf8=✓#L1278

Also, you need to do it using this filter: https://github.com/rtMediaWP/rtMedia/blob/master/app/main/controllers/template/rtmedia-functions.php?utf8=✓#L1305

Here is the small example which will display gravtar:

function rtmedia_custom_comment_template( $html, $comment ) {
    if ( function_exists( 'rtmedia_author_profile_pic' ) ) {
	    $html .= rtmedia_author_profile_pic( $show_link = true, $echo = false, $comment['user_id'] );
    }
    return $html; 
}
add_filter( 'rtmedia_single_comment', 'rtmedia_custom_comment_template', 10, 2 );

#3