Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Plugin: glx_gravatar
Outputs a users Gravatar in comments. More info about Gravatars at http://www.gravatar.com/
Place this tag in a comment form to output a users Gravatar.
Name: glx_gravatar
Version: 0.2
Download URL
More details
Note! This plugin requires 1.0RC3 rev180 or greater
note: graumeister is now maintaining and has taken ownership for this plugin.
Last edited by osei (2005-08-20 05:34:04)
Johan Nilsson
Offline
Re: Plugin: glx_gravatar
Very nice osei. Worked first time thanx.
Stuart
In a Time of Universal Deceit
Telling the Truth is Revolutionary.
Offline
#3 2005-03-12 19:27:43
- playpiggy
- Member
- From: Changchun, China
- Registered: 2004-11-23
- Posts: 55
Re: Plugin: glx_gravatar
Thank you osei.
No hack needed any more.
Welcome to the REAL World…
Offline
#4 2005-03-17 00:20:10
- Andrew
- Plugin Author
- Registered: 2004-02-23
- Posts: 730
Re: Plugin: glx_gravatar
Hey johan, I’ve modified your plugin in a few ways to make it a little more gravatar-friendly.
First and foremost, Gravatars are quite tempermental and the rule of thumb for them is to only pass them the gravatar_id if at all possible. The Gravatar servers resize the graphic for you and many things can corrupt a transparent background: the ‘default’ parameter, the “wrong” size value (different for all gravatars & browsers), the list goes on and on. Gravatars may be easily (and should be) resized with CSS, which will always preserve transparency.
Secondly, a 1×1 pixel gif Gravatar will be returned if a) the gravatar id doesn’t exist or b) the gravatar is restricted by too high a rating. So what I’ve done is this:
- All querystring parameters now are completely empty by default if not user-specified (even “size” — trust me, it’ll avoid problems)
- Added a preliminary check of the gravatar_id & rating to see if it returns a 1×1 gif
- If 1×1 gif:
- Return either the image tag with the specified default image, or nothing at all (default image no longer passed to gravatar.com)
- If gravatar:
- Return image tag with path to gravatar (no real need to pass ‘default’ parameter anymore)
I’ve tested it lightly, so be sure to try it out a bit, but it seems to work well. This way it’ll both preserve the gravatar’s integrity (assuming the user is using CSS for sizing) and it won’t add an empty 1px gif to your layout.
This is impossible to post to the forum because of textile, so here’s a link to the altered function.
Last edited by Andrew (2005-03-17 04:08:34)
Offline
Re: Plugin: glx_gravatar
Thanks Andrew that is some great improvements, oss is really great :)
I updated the link in the first post so it now includes your improvements, I also added a check for is_numeric on the size value.
Johan Nilsson
Offline
Re: Plugin: glx_gravatar
Johan, very nice plugin. I always hesitated to implement gravatars but this makes it so easy.
The problem I have might not necessarily be a result of the plugin, but something that comes along with using gravatars. What I’m seeing is some extremely slow page runtimes for articles that have a lot of comments. For one post that has 43 comments, I’m getting runtimes in the 12-15 second range while a post with only 5 comments has a 1.5 second load time.
Is anyone else seeing this? I’ve checked some other TXP sites and seen runtimes upwards of 25 seconds on posts with a lot of comments. Is this something I’m stuck with if I want to use gravatars?
Offline
#7 2005-04-14 07:08:01
- Andrew
- Plugin Author
- Registered: 2004-02-23
- Posts: 730
Re: Plugin: glx_gravatar
poop.
I think my attempts to improve may be ultimately not improvements. I just spoke to alicson regarding your issues & the solution you described & you’re right – the plugin is now making double the http requests.
I think the ideal solution, rather than checking if a 1×1 pixel image was returned from gravatar, is just to always use the gravatar in combination with a CSS-styled background image (wilshire’s suggestion to alicson). So if you get a 1×1 pixel transparent gif in return (because the gravatar doesn’t exist for the email address) then all you will see is the background image for the container div or span that is wrapping your gravatar.
The reason I initially thought to implement the changes I did was because of the way the Gravatar server totally screws up gravatars if you request a default image and a custom size. It seriously jacks them up and it sucks.
Pretty much the only way you can request a gravatar and be sure it won’t screw up is by using only the base url w/ email md5 hash (no extra parameters). Once you add the &default=
or &size=
, you’re going to start getting black backgrounds and broken gravatars.
Anyways, I think reverting to an older version while somehow sidestepping some of the adding of empty parameters to the querystring would be a good solution for now.
But in the long term, I’m guessing this plugin will change drastically because of the recent REST API. This now provides the ability to check 404 vs 200, and since it’s an xml response you /could/ in theory cache the results for email addresses (although would that sort of defeat the purpose of REST?).
So… what do you think, johan? Revert?
Offline
Re: Plugin: glx_gravatar
When I first tried Gravatars using the original Gravatar supplied hack I was finding I got long load times with posts that had a large number of comments. In fact I got fed up with it and took them out. I put it down to heavy server loads at the Gravatar end. Since installing Johan’s plug-in I haven’t noticed the problem though I haven’t had 40 odd comments for a post recently. Still, I do have several in the 20s and I’m not seeing any problems. I am still on version 0.1 though and reading Andrew’s comments I’m not thinking of upgrading it at this time. I did wonder if these things couldn’t be cached in some way.
I have also spotted the problem with transparent backgrounds going black and advised 1 or 2 of my commenters to change their Gravatar after which there was no problem. I understood this was something to do with down-sizing. I think 80 × 80 is far too large for most people. They ought to drop it to 50 × 50. If you want to reduce them futher it’s down to you but at least I think 50 × 50 is a usable size.
Whilst I’m here how do you show runtime “on-screen”?
Last edited by thebombsite (2005-04-14 09:04:01)
Stuart
In a Time of Universal Deceit
Telling the Truth is Revolutionary.
Offline
Re: Plugin: glx_gravatar
I try to use the plugin glx_gravatr but everytime there is no gravatar I get the followin error message:
Warning: getimagesize(): URL file-access is disabled in the server configuration in /home/www/web171/html/textpattern/lib/txplib_misc.php(304) : eval()’d code on line 700
Warning: getimagesize(http://www.gravatar.com/avatar.php?gravatar_id=29402a43afdde10b863aa779bfefe496): failed to open stream: no suitable wrapper could be found in /home/www/web171/html/textpattern/lib/txplib_misc.php(304) : eval()’d code on line 700
Warning: getimagesize(): URL file-access is disabled in the server configuration in /home/www/web171/html/textpattern/lib/txplib_misc.php(304) : eval()’d code on line 700
Warning: getimagesize(http://www.gravatar.com/avatar.php?gravatar_id=eb63f936f98f52390e69f8c1f95bc19c): failed to open stream: no suitable wrapper could be found in /home/www/web171/html/textpattern/lib/txplib_misc.php(304) : eval()’d code on line 700
If there is a gravatar on gravatar.com there is no problem at all!
Offline
Re: Plugin: glx_gravatar
Sorry I hope my provider will aktived the function URL file-access i think this should solve the problem ; ) Sorry for posting this error message
Offline
Re: Plugin: glx_gravatar
I was going to post what I found last night but you already hit the nail on the head Andrew.
I was noticing the same type of performance that you mention Stuart so I commented out these lines in the plugin:
<code>
//$image = getimagesize($grav_base_url); // check url with only gravatar_id & rating
//if ($image0==1 && $image1==1 && $image2==1) { // is it 1×1 & gif?
// return (!empty($default))
// ? ‘<img src=”’.$default.’” alt=”’.$alt.’”’.$class.’ />’
// : false;
//}
</code>
Then I added a CSS background image on the block where the gravatar would appear. If a gravatar exists, it overlays my background image. On a post with 43 comments I saw my runtime drop from 14 seconds to .14 seconds.
Last edited by wilshire (2005-04-14 12:19:40)
Offline
#12 2005-04-14 15:30:39
- Andrew
- Plugin Author
- Registered: 2004-02-23
- Posts: 730
Re: Plugin: glx_gravatar
I’d like to look into expanding this toward the REST API. Perhaps I’ll take a look into other plugins/implementations to see how people are using it.
Offline