• Fig X. Widget control options.

  • Fig 5. Optional widget.

Avatars Plugin

New Version (v11.1), released August 2012

WordPress (from version 2.5) includes native support for global avatars. Great! 🙂 But, what about adding local (private) avatars for your users? Maybe your users don’t want a global avatar, aren’t IT savvy enough to set a Gravatar up, simply want a private avatar for your blog, or any other reason too…

Please note, from v9.0 Avatars requires PHP version 5.1.3 or greater.

This plug-in does exactly that – users may add the ability to have a global (Gravatar), Twitter, or local avatar on your WordPress site. I’m quite pleased with it. 😳 So, I think it is worth shouting about, and sharing…

The plug-in is available as a free download here.

All I ask is that you credit the widget (i.e. include a link to this blog, enable the author credit option, or maybe add a link on your blogroll). Of course donations are an awesome way to recognise any value you get from using the plugin or encourage continuing development…

Plus there is also a sidebar widget extension to the plug-in that provides a feature allowing users to manage their avatar from the sidebar without having to use WordPress’ profile administration page. It provides the same capability as the profile page. This feature provides yet more support for users who may not, for example, be savvy enough to use the WordPress administration interface. I’m asking for a super-small fee (just £3.50) for this extension.

Local Avatars Widget

[SKU23484] £3.50 (Shipping £0.00)

Approximately one hour after payment your plugin will be emailed as a compressed ZIP to you PayPal payment address.

This small fee does not allow for any customisation of the widget, extra features, resolution of clashes with other WordPress plug-ins or themes, etc. So, please let me know if you want those and we can talk about options – who knows it might be such a killer idea that I’ll add it to the widget anyhow! However, the fee does include bona fide bug fixes; find something wrong with the plug-in, and I’ll fix it as quickly as possible.

Instructions to get the optional extension:

  • Click on the Buy Now button above and buy the extension securely via PayPal.
  • Then please be patient, PayPal will e-mail me and I will get straight back to you via e-mail with the extension and simple installation instructions.
  • This extension requires the Avatars plug-in, download it free (link above).
  • Please note, the widget is called User Avatar in the WordPress Widgets interface.

:star: Why not check out my other WordPress plug-ins too! :star:

The Avatars plug-in delivers the much requested feature of allowing users to upload their own local avatar. And, the latest feature allows your users to use their Twitter avatar. The order of precedence is; Local, Twitter, then Global. In other words, if you define a Local avatar for a user, that will be used, if there is no Local avatar defined and a Twitter ID is given for a user, the plugin will try to use that avatar. Lastly, where no Local avatar is defined and no Twitter ID is given (or Twitter doesn’t return a match), a unique Global avatar (Gravatar) will be generated.

Both of these features can be turned on and off by Administrators.

Features:

  • Have global or local avatars for your users.
  • Use Twitter avatars for your users.
  • Allow avatars to be included, securely, in your posts.
  • Detailed control over the default avatar to use for those users who have no global or local avatar. Allows a choice of a custom image, ‘mystery’ blank image, blank, Wavatar, Monster ID, or Identicon.
  • Wraps avatars in code to support SnapShots (www.snap.com), should your site use these.
  • Permits users to upload their own local avatars.

Example Screens

Avatars:

Fig 1. An example of the main avatars page. Manage users global and local avatars etc.

Fig 2. The avatars options configuration section of the main avatars page.
Fig 3. From the WordPress profile page, the new section allows users to upload their own local avatar.
Fig 4. Popup used to manage Avatar images.

Optional Widget:

Fig 5. Widget control options.

Fig 6. Optional widget.

Instructions:

  • Just put the plug-in into your plug-in directory on your WordPress hosting account (if this doesn’t make sense it probably isn’t something you should be trying 🙂 ) and activate it.
  • Use the form, Users » Avatars, to define any local avatars for your users. Specify the URI for an avatar image, something like http://your.domain/avatars/image.jpg, where avatars is a directory containing your local images.
  • Also you may set a default size (in pixels) for avatars and define a default image (e.g. http://your.domain/avatars/default.jpg) to use when no local or global avatar is available.
  • The code to include in your template files is documented on the Users » Avatars page too. To start with try:
    • Put get_avatars($comment); inside the comments loop of your comments.php template file to show the comment author’s avatar.
    • Put get_avatar($post->post_author); in your single.php template file to show the post author’s avatar. You’ll need to declare global $post; in the file too.
  • Make use of this feature to generate a unqiue Wavatar (other options exist).

Internationalisation:
Avatars provides support for language translations. Ensure WPLANG is set in your wp-config file. To help with the available translations create a .po translation and compile a .mo file. If you would like this to be included in the general distribution please send these files back via the feedback link. I can’t accept any credit for these languages files, nor can I guarantee they are correct.

Available translations, from the English default, are:

  • Persian (WPLANG = fa_IR). Thanks to Mustafa Sufi.
  • Russian (WPLANG = ru_RU). Thanks to Fatcow.
  • French (WPLANG – fr_FR). Thanks to Adrien Schvalberg.
  • Spanish (WPLANG – es_ES). Thanks to Naceira.
  • Ukrainian (WPLANG – uk_UK). Thanks to Vadim Nekhai.
  • Portuguese Brazil (WPLANG – pt_BR). Thanks to Steff.
With regret I have closed comments on this post as I’m being deluged with queries that often boil down to “how to” requests, PHP coding advice, etc. and not issues with the Avatars plug-in or widget. So, if you want support, even advice, use the Feedback link and ask away… But please note I will ask for a donation before I’ll look at anything not related to Avatars bugs – I can’t teach PHP programming or WP configuration for free.

Version History:

  • 11.1 – Sanitize upload filenames.
  • 11.0 – Crop user upload image for use as avatar. Thanks to Barry Israel for the inspiration.
  • 10.7 – Accidental removal of user editing avatar uploading section, now back where it should be!
  • 10.6 – Avatar settings link.
  • 10.5 – Small change to hack for new (WP 3.3) Admin Bar style.
  • 10.4 – Add ‘retro’ dynamic automatic Avatar type.
  • 10.3 – Compress the paging header for Avatar tables, plus tidy up of table output code.
  • 10.2 – alt tag for avatar img.
  • 10.1 – Update for networked WP. Thanks to Michael D Tran.
  • 10.0 – New option to upsize local avatar images that are smaller than the set size. Thanks to Nicholas Craig.
  • 9.2 – Fix for local avatar upload to cope with the ever changing WP!
  • 9.1 – Update for Admin Bar in WordPress v3.1
  • 9.0 – WPMU/Network re-work. Thanks to Michael D. Tran for his efforts!
  • 8.3 – Allow Twitter ID for optional widget.
  • 8.2 – Control anchor wrapping of Avatars.
  • 8.1 – Simplified Twitter image URL logic.
  • 8.0 – Added option to try to use a Twitter avatar.
  • 7.6 – Check for required core WP upload functions, only required for themes that expose the user profile pages.
  • 7.5 – Use DOCUMENT_ROOT option for legacy users.
  • 7.4 – Root directory no longer DOCUMENT_ROOT.
  • 7.3 – Fix for user avatar upload that doesn’t need re-sizing and a Russian translation thanks to “Fatcow”
  • 7.2 – Class added to help with styling widget.
  • 7.1 – Update for Marc Adrian to provide support for option for showing text in the optional widget.
  • 7.0 – Support for user profile widget plug-in.
  • 6.8 – Option for nickname / first name & surname.
  • 6.7 – Fix for uppercase extensions.
  • 6.6 – Fix to scaling when upgrading from old version of plug-in without scaling option.
  • 6.5 – Upload file type check (thanks to SumoSulsi) and internationalisation preparation.
  • 6.4 – Error in file naming fixed, with some help from “noyz319”.
  • 6.3 – Oops, a bug (mistake) with the scaling size fixed.
  • 6.2 – Improved unique file name creation, optional avatar upload resizing/cropping, and PHP 4 fix. Thanks to Gioele Agostinelli.
  • 6.1 – Explanation of directory structure and ‘chmod’ fix, thanks to Tobias Schwarz.
  • 6.0 – Added feature to allow users to upload their own avatar.
  • 5.2 – Cope with WP 2.6 avatar default.
  • 5.1 – Minor fix to repetition of show avatars WordPress setting.
  • 5.0 – Avatar options should only be managed by Administrators.
  • 4.2 – Fix for credit option un-setting.
  • 4.1 – Author credit.
  • 4.0 – Wavatar, Monster ID and Identicon can be used.
  • 3.3 – Spelling fixes!
  • 3.2 – Added check for administration pages to stop user URL wrapping breaking comment editing.
  • 3.1 – Minor tweaks to usage text and options.
  • 3.0 – Added ability to place avatars in written post content (plus other tweaks).
  • 2.1 – Added example formatting information.
  • 2.0 – Added pagination of the commenters list too.
  • 1.0 – Added pagination of users list.
  • 0.1 – Initial release.

Series - WordPress Plug-ins

  1. Image Link WordPress Plug-in
  2. Last Year WordPress Sidebar Widget Plugin
  3. Simple Archive Plugin
  4. Avatars Plugin
  5. WordPress Post Country Plugin
    (with premium Google Mapping)
  6. Notices Ticker Plugin
  7. Comments with Avatars
  8. Simple WordPress Twitter Plugin
  9. WordPress Post Grouping Plugin
  10. WordPress Mapping Plugin

62 thoughts on “Avatars Plugin”

  1. What parameters do I enter in this code, and how do I enter them:

    I entered 30 for 30px, but I only get the default avatar.

    My local avatar location is /wp-content/gravatars/local/. I entered this in Design -> Theme Editor -> User -> Avatars.

  2. The configuration options are under the Users menu on the Avatars item… Just like it says under the instructions above. 😉
    You need to enter the path and filename of the local avatar – check the example above (3rd bullet of the instructions). Good luck.

  3. On the Users » Avatars page it lists the first 50 users on the blog, but there doesn’t seem to be any pagination, how do I get to the other users?

  4. Patung, there is no limit on the number returned and there is no pagination (just a simple list). So, are you sure you don’t have just the 50 users? correction, there is a limit set by WordPress! I will fix this and get an updated version out ASAP.

    Update: Now fixed for user paging! Download from this page (link above) or wait till the WordPress.org hosting refreshes.

  5. Dmitry, users cannot upload their own avatars. The admin must set them up; put the image files in a directory somewhere (e.g. /wp-content/avatars/) and then set them up under the Users >> Avatars menu…

  6. I’m thrilled there’s something out there like this! I’ve always thought avatars/userpics/icons were a basic part of blogs… I was surprised to not see it part of the default WP package!

    I’m wondering if there’s a way to allow an “Upload” system, even if only the Admin can set them up. E.g. some sort of “Upload” button that would take care of uploading the image and putting it in the proper directory. Would a future release maybe allow for the Admin to set users with the privileges to pick their own avatar?

  7. Sorry Eh, I don’t think you are using the plug-in correctly. Are you using WordPress version 2.5? Just put the URI of a default image in as the default. If you put the same thing into your browser’s address bar it should show the image, if it doesn’t it’s wrong! So, there’s no way the plug-in can use it…

    Hmm, and 1 error (of your making, not the plug-in at all) isn’t really “tons” is it! 😐

  8. This is a goofy question, but what are the template files where I might put ? If I want the avatar to appear in the upper left of every post, or maybe in the footer of the post, next to the author name, what file would be appropriate for that?

  9. I put get_avatars($comment); inside the comments loop of my comments.php template file to show the comment authors avatar, and get_avatar($post->post_author); in my single.php template file to show the post author’s avatar.

  10. Are the comments.php and single.php pages you mentioned part of the default WP package? Where would I find them? (I’ve looked, but don’t see anything by those names, so I’m wondering if the names are different, or if I’m just looking in the wrong places.)

  11. Nollie, please check out the various references to HTML available on the web – just Google for what you want… 😉
    Something like style="float: right;"

  12. Pete, I have avatars working on my comments, but I can’t get them to work on my single.php page. I keep getting this error:

    Warning: Missing argument 1 for get_avatar() on line 28

    I don’t think I have: get_avatar($post->post_author); in the right place.

  13. Craig, you may need to have this declaration, <?php global $post; ?>

    Other than that I can’t really help – it could be any number of problems with your template file that I nor the plug-in have any control over… 🙁

    Update: now (May) fixed in any case

  14. Pingback: Leonaut.com
  15. Just a note to thank you for your excellent Avatars plugin. I’m in the process of designing a blog for the Royal Society of Chemistry, and found your plugin very easy to use. I hope you don’t mind that in the version I’m using, I changed a value in the avatars.php to allow 90×90 avatars – the options list only went to 80. If this change is unacceptable please let me know and I’ll return to the original.

  16. I just wanted to drop a line and say “great job” on the local avatar WordPress plugin. It was exactly what I was looking for! Thanks a bunch!

  17. Been using your Avatar plugin for the past week and just installed the update. Wanted to drop by and say great job, simple, typical install, easy to configure and just works. Most pleased. Looking at your site I notice your “Rated Images” and “Recent Comments” and would like to know what plug these are. Be nice to add a rotating image such as yours and the avatar next to the recent comments is a nice touch. Appreciate it, keep up the good work.

  18. Pingback: Using Avatars Plugin :BlogCashMentor.Com
  19. Pingback: Fix your Avatar!
  20. Pingback: Anonymous

Comments are closed.