Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2005-03-10 09:10:27

osei
Plugin Author
From: Stockholm, Sweden
Registered: 2004-07-01
Posts: 178
Website

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

#2 2005-03-10 23:33:58

thebombsite
Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

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

#5 2005-03-17 16:11:48

osei
Plugin Author
From: Stockholm, Sweden
Registered: 2004-07-01
Posts: 178
Website

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

#6 2005-04-14 01:26:31

wilshire
Plugin Author
From: Akron, Ohio
Registered: 2004-08-27
Posts: 656
Website

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

#8 2005-04-14 08:52:00

thebombsite
Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

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

#9 2005-04-14 09:19:53

Freigeist
Member
Registered: 2004-11-01
Posts: 13
Website

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

#10 2005-04-14 09:50:23

Freigeist
Member
Registered: 2004-11-01
Posts: 13
Website

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

Board footer

Powered by FluxBB