Add aditional class to get_avatar when showing image


I want to add bootstrap img-responsive and img-rounded classes to avatar image when displaying one. But for some reason the class is not displayed when using get_avatar.

By WordPress codex there is an attributes list that you can use in get_avatar to alter the function but my doesn’t pickup class array list.

Here is current code that i use.

get_avatar( $current_user->user_email, 128, null, null, array('class' => array('img-responsive', 'img-rounded') ) );

By explanation last parameter is arguments array in which you can use size , height , width etc… among those is class which can be array or string.

So i tried a few combinations

$args = array(
   'class' => 'img-responsive img-rounded'
get_avatar( $current_user->user_email, 128, null, null, $args );

I also tried

$args = array(
 'class' => array( 'img-responsive', 'img-rounded');

But for some reason class is not accepted.

, Aleksandar Dordevic 3 years 2020-04-04T00:55:33-05:00 0 Answers 86 views 0

Leave an answer