[Avatars] Adding class to Avatar

I'm trying to add a class "rounded-circle" to the avatar. With WordPress' standard avatars (gravitar) the following code works, but not when using Avatars plugin.

`get_avatar(get_current_user_id(), '60', null, null, array( 'class' => array( 'rounded-circle' ) ) );`

How can I add a class when using Avatars plugin?

  • Adam Czajczyk

    Hello Tedster

    I hope you're well today and thank you for your question!

    I have tested this on my end and can confirm the issue. I've checked the plugin and it turns out that it "ignores" the "class" attribute.

    To fix this, changes in plugin's code are necessary. As a "quick patch", I've attached the "avatars.zip" file to this post so if you wish to give it a go, please follow these steps:

    1. download and extract an attached .zip file to your local drive
    2. access your server (site install) via FTP or cPanel's File Manager
    3. upload "avatars.php" file from inside attached .zip to the /wp-content/plugins/avatars/ folder of your site install, overwriting existing file.

    This will make the plugin "aware" of the "class" argument and your function call should be working fine then.

    Please note: this is a change in plugin code and plugin's update might overwrite it, unless the fix is included in update. I've already reported it to our developers along with a proposed fix though.

    Best regards,
    Adam

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.