I recently found this cool wordpress twitter avatar plugin from smashing magazine that displays the twitter avatar for those who don’t have a gravatar or prefer the twitter image.
Unfortunately the plugin doesn’t work with the new Twitter API and it looks like the talented developer has taken a vacation.
Luckily I saw that a user had posted a fix to the thread on smashing mag and I made their suggested change to get things to work. However there is a pretty serious flaw to the suggested change, that is – the plugin will then simply look at the first part of the email (before the @ sign) and use the twitter account image it finds there, regardless of if the email entered is a twitter email or not. So needless to say I had a lot of interesting photos appearing alongside comments in my blogs…
So for a quick fix, I changed the code to check for @twitter.com and changed the label of the field to indicate a way to use the twitter avatar. You can see it in action on my beer blog. I am using WordPress 2.8.3 there and with this quick change the twittar plugin works well.
If you want to try this out the original plugin “Twittar” can be downloaded here. I am sure that there are many better ways to accomplish this, and I am looking forward to the promised Twittar2 coming soon. But for a quick fix – around line 150 find:
function showUser($id){
// Will arrange the url we need to open @ twitter to get the photo info
$request = 'http://twitter.com/users/show/show.xml?email='.urlencode($id).'';
// Will open another function that will do all the hard work ![]()
return process($request);
}
and replace it with:
function showUser($id){
$pos = stristr($id, ‘twitter’);
if ($pos === false) { return process(‘static.twitter.com’);
} else {
$id = explode(‘@’, $id);
$id = $id[0];
// Will arrange the url we need to open @ twitter to get the photo info
$request = ‘http://twitter.com/users/’.strval($id).’.xml’;
// Will open another function that will do all the hard work ![]()
return process($request);
}
}




