Adding Local Avatars in WordPress

Adding Local Avatars in WordPress

Adding Local Avatars in WordPress

One of our readers Hariom wanted to know how to add profile images or avatars for WordPress users. Gravatar is one of the easiest solution to add avatars with user or author biography in WordPress. But Hariom was going to have the WordPress on a local network without access to the Internet. How to add author/user avatar without having to use Gravatar? How can one upload his own images to be used as avatar?

Simple Local Avatars WordPress plugin adds a new option in user profile page and allows you to upload your own image to be used as avatar. It is very similar to Gravatar. Download and install the plugin to your WordPress website.

Now, go to WordPress Dashboard -> Users -> Profile. You will find a new upload button for avatars. Once you have uploaded your image, the plugin will crop and resize it into a square thumbnail. It will output your image when the theme requires an avatar. If you have not uploaded any avatar, it checks Gravatar and then falls back to default icon.

How to output avatar in your theme?The code for displaying avatar in WordPress theme will be the same as Gravatar. You need to use get_avatar tag for displaying the avatar in the following format.

<?php echo get_avatar( get_the_author_meta( 'user_email' ), 60 ); ?>

You can modify the size of avatar by replacing “60″ in the code with your desired size anywhere from 1px up to 512px.

Comments

  1. Well, every piece of code i’ve tried… including this one does not work. Yes it will pull the GRAVATAR image… that is NOT what users want. We want code that will pull the user uploaded image and display it.

    so doesn’t work for that.

    • Hi Josh, This plugin allows your WordPress website users to add their own avatars. It shows Gravatar image only if you have not uploaded your own iomage on the website. Hope it makes things clear. Thanks

Speak Your Mind

*