BLOGIOLOGI
.. an e-sharing about blogging, WordPress, SEO, make money online and a couple of my personal notes

How to Display Twitter Avatars in WordPress Comments

9 months and 9 days ago
By abbie

As you know that WordPress has an option to display gravatars in the comment for your users. Well sometimes users don't have a gravatar account, but they have a twitter account. In this article we will share a way for you to combine gravatar and twitter avatars to display in your comment area.

What does this plugin do?

  • Loads user's avatar by matching the email address to the user's Twitter email address.
  • If user doesn't have a Twitter account, it first tries to load user's gravatar. If user doesn't have a gravatar, it loads a default image. This is an optional setting.
  • You can set a 2-pixel border to the images (you choose the color).
  • You can choose the sizes: Preferred ones are 24, 48 or 72 pixels.
  • You can set an image other than the default one to load if a user doesn't have a Twitter account or a gravatar.
  • It builds a valid image for you (with alt and title attributes, etc.) based on user details.
  • Allows you to add a class to the image, so you can style it later.

Installation Guide

First download and activate the plugin. Then you would need to place this code in your comment(s).php where you want to display the avatar.

<?php twittar(size, placeholderimg, border, class, usegravatar, rating); ?>

Now you would need to change the parameter in the code using the guide below:

size
The size of the avatar (in pixels). Just insert the number (e.g. 45), without «px.» It is the size for both width and height.

placeholderimg
The URL for the image you want to use when the user has neither a Twitter account nor a gravatar. Must be inside quotes (»»). Optional.

border

The color for the 2px border. Insert the hexadecimal code of the color (e.g. «#FFFFFF» with the «» marks) but only if you want to use one.

class
A CSS class that you want to use to style the avatar. For example: «myimg.» In the CSS, you would include .myimg { }. Put inside «».

usegravatar
Just insert 1 if you want to use gravatars, and 0 if you don't. If you choose to use gravatars, it will try to load a gravatar image if a Twitter account and picture is not found, otherwise it will load the placeholderimg (default) image directly.

rating
Parameter for gravatars only. Read more at www.gravatar.com.

Note: if you want to skip a parameter and add another in front of it, just replace it with «».

For Example:

<?php twittar(«45», «», «», «myimg», 1, «R»); ?>

License: The plug-in is released under the GPL. You can use it for all your projects for free and without any restrictions. You may modify the plug-in as you wish.

Download the Plugin

Source: Smashing Magazine

Belajar Web Bisnis

7 comments

Gravatar #1. rismaka
9 months and 7 days ago

Assalamualaikum gan :D

Maaf baru bs berkunjung, maklum baru bs libur lebaran ini.. Pa kbr neh? Wah tambah berat aj artikel2nya :lol:

Hmm... Saya dulu pengen nyoba avatar twitter, tp yg pake fungsi, bkn pake plugin, tapi ga jd, coz ga smua blogger pnya akun twitter. Ya udh deh terpksa dibatalken.

Gravatar #2. abbie
9 months ago

Wa'alaikumussalam Gan..
Trm ksh sdh berkunjung. Kabar sy alhamdulillah baik. Hiatus hampir 2 bulan nih Gan. he..he..
Postingan tambah berat? Gak juga. Ini bukan tulisan saya. Asli pke RSS aggregator. :)

Gravatar #3. laser hair removal nyc
4 months and 16 days ago

What template do you use in your site

Gravatar #4. unlock iPhone 3G
4 months and 16 days ago

I want to subscribe to your site, do you have newsletter ?

Gravatar #5. make money online
4 months and 15 days ago

I searched many websites and here i found what i was looking for, thanks for valuable post

Gravatar #6. rismaka
4 months and 13 days ago

I searched many websites and here i found what i was looking for, thanks for valuable post :lol: :lol:
rismaka's last blog.. Memblokir Iklan Lokal Menggunakan Adblock Plus My ComLuv Profile

Gravatar #7. cichodajki
4 months ago

Do you know where to find paid templates for my blog, i got blog on the same cms like yours.

Write a comment

If you want to add your comment on this post, simply fill out the next form:





CommentLuv Enabled

* Required fields

You can use these XHTML tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>.

No trackbacks

To notify a mention on this post in your blog, enable automated notification (Options > Discussion in WordPress) or specify this trackback url: http://​blogiologi.com/​how-to-display-twitter-avatars-in-wordpress-comments/​trackback/