Thread Starter
Win Win
(@aminericher)
This is the code I use to display the avatars for the authors (instructors) of the custom post_type (course)
function bp_course_get_instructor_avatar( $args = array() ) {
$defaults = array(
'item_id' => get_the_author_meta( 'ID' ),
'object' => 'user'
);
$r = wp_parse_args( $args, $defaults );
return apply_filters('wp_display_course_instructor_avatar',bp_core_fetch_avatar( $r ),get_the_ID());
}
Anything outdated or conflicting with the plugin ?
Hi there,
There are different sources for my plugin to take letter from. Most likely here it is trying to take the letter from the alt attribute in avatar’s img tag. What is the alt attribute in these avatars? If there is none, my plugin will take the letter of the logged in user. Usually in BuddyPress the alt attribute for avatars is Profile picture of XXX or Profile photo of XXX.
Kind regards,
Daniel Wroblewski
Thread Starter
Win Win
(@aminericher)
Hey, thank you for the quick response.
The alt attribute in this avatars is only Profile photo with no indication to the user. The user id is mentioned in the class of the img. How should I add the username to alt in the code above ?
Many thanks.
How about this:
function bp_course_get_instructor_avatar( $args = array() ) {
$author_name = get_the_author_meta( 'display_name' );
$author_id = get_the_author_meta( 'ID' );
$defaults = array(
'item_id' => $author_id,
'alt' => 'Profile picture of ' . $author_name,
'object' => 'user'
);
$r = wp_parse_args( $args, $defaults );
return apply_filters('wp_display_course_instructor_avatar', bp_core_fetch_avatar($r), get_the_ID());
}
I haven’t tested it.
Thread Starter
Win Win
(@aminericher)
It’s working !
Thank you Daniel, I am very grateful for you!
Great, thanks for letting me know. If you like the plugin, please leave a rating 🙂
Kind regards,
Daniel Wroblewski