How to change class of group avatar ?
-
Hello,
I would like to add the class ‘thumbnail’ to the group avatar with this filter but for some reason it returns an error saying “Illegal string offset ‘class’ “. What could be the reason ?
function.php :
// Add class to Group avatar image function bp_add_class_thumbnail_group_avatar( $avatar ) { $avatar['class'] .= ' thumbnail'; return $avatar; } add_filter( 'bp_get_group_avatar', 'bp_add_class_thumbnail_group_avatar' );
The original class is set by the function bp_core_fetch_avatar inside bp_get_group_avatar but it is not clear for me how to address this sub-function.
If somebody have an idea,
Thank youfunction bp_get_group_avatar( $args = '' ) { global $groups_template; // Bail if avatars are turned off. if ( bp_disable_group_avatar_uploads() || ! buddypress()->avatar->show_avatars ) { return false; } // Parse the arguments $r = bp_parse_args( $args, array( 'type' => 'full', 'width' => false, 'height' => false, 'class' => 'avatar', 'id' => false, 'alt' => sprintf( __( 'Group logo of %s', 'buddypress' ), $groups_template->group->name ) ) ); // Fetch the avatar from the folder $avatar = bp_core_fetch_avatar( array( 'item_id' => $groups_template->group->id, 'title' => $groups_template->group->name, 'avatar_dir' => 'group-avatars', 'object' => 'group', 'type' => $r['type'], 'alt' => $r['alt'], 'css_id' => $r['id'], 'class' => $r['class'], 'width' => $r['width'], 'height' => $r['height'] ) ); // If No avatar found, provide some backwards compatibility if ( empty( $avatar ) ) { $avatar = '<img src="' . esc_url( $groups_template->group->avatar_thumb ) . '" class="avatar" alt="' . esc_attr( $groups_template->group->name ) . '" />'; } /** * Filters the group avatar while in the groups loop. * * @since 1.0.0 * * @param string $avatar HTML image element holding the group avatar. * @param array $r Array of parsed arguments for the group avatar. */ return apply_filters( 'bp_get_group_avatar', $avatar, $r ); }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘How to change class of group avatar ?’ is closed to new replies.