View Issue Details

IDProjectCategoryView StatusLast Update
0010850mantisbtfeaturepublic2011-08-18 06:11
Reportersdurkin Assigned Tojreese  
PrioritylowSeveritytweakReproducibilityalways
Status closedResolutionfixed 
Product Version1.2.0rc1 
Target Version1.2.5Fixed in Version1.2.5 
Summary0010850: Gravatar code wrong
Description

In 1.2.0rc1, the code generated for Gravitars is ...

<img
class="avatar"
src="http://www.gravatar.com/avatar.php?
gravatar_id=63905e29cdedf189b53cd0efeb973ae1&
default=http%3A%2F%2Fwww.mantisbt.org%2Fbugs%2Fimages%2Fno_avatar.png&
size=80&
rating=G"
alt="User avatar"
width="80"
height="80"/>

This currently works, but as you can see from the gravatar spec ...
http://en.gravatar.com/site/implement/url

it is incorrect. For better future-proofing, the code should be changed to something like ... (I hope my entered formatting is preserved).

<img
class="avatar"
src="http://www.gravatar.com/avatar/63905e29cdedf189b53cd0efeb973ae1.jpg?
default=http%3A%2F%2Fwww.mantisbt.org%2Fbugs%2Fimages%2Fno_avatar.png&
size=80&
rating=G"
alt="User avatar"
width="80"
height="80"/>

Tagspatch
Attached Files
gravatar_url_2011-05-04.patch (989 bytes)   
From 49b9da249dea883ceb2db83e4e579cda176400f0 Mon Sep 17 00:00:00 2001
From: Dominik Blunk <dominik@blunk.ch>
Date: Tue, 5 Apr 2011 10:38:42 +0200
Subject: [PATCH] Modified gravatar url to meet gravatars updated specification
 http://en.gravatar.com/site/implement/images/

---
 core/user_api.php |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/core/user_api.php b/core/user_api.php
index 918bce9..dfad5ca 100644
--- a/core/user_api.php
+++ b/core/user_api.php
@@ -815,7 +815,7 @@ function user_get_avatar( $p_user_id, $p_size = 80 ) {
 			$t_gravatar_domain = 'https://secure.gravatar.com/';
 		}
 
-		$t_avatar_url = $t_gravatar_domain . 'avatar/' . md5( $t_email ) . '&default=' . urlencode( $t_default_image ) . '&size=' . $t_size . '&rating=G';
+		$t_avatar_url = $t_gravatar_domain . 'avatar/' . md5( $t_email ) . '?d=' . urlencode( $t_default_image ) . '&s=' . $t_size . '&r=G';
 		$t_result = array(
 			$t_avatar_url,
 			$t_size,
-- 
1.7.3.1.msysgit.0

Activities

sdurkin

sdurkin

2009-08-19 04:14

reporter   ~0022762

Also, it would be really good if administrators could turn on wavatar or monsterid defaults.

Eg:
http://www.gravatar.com/avatar/3b3be63a4c2a439b013787725dfce802?d=identicon
http://www.gravatar.com/avatar/3b3be63a4c2a439b013787725dfce802?d=monsterid
http://www.gravatar.com/avatar/3b3be63a4c2a439b013787725dfce802?d=wavatar
http://www.gravatar.com/avatar/3b3be63a4c2a439b013787725dfce802?d=404

sdurkin

sdurkin

2009-08-19 04:55

reporter   ~0022763

Forget the wavatar thing. I just noticed you can set:
$g_default_avatar = "wavatar";
in file config_inc.php and this will enable Wavatars!
Nice one.

sdurkin

sdurkin

2009-08-19 05:10

reporter   ~0022764

I can see that the code snippets from the developer resources on the Gravatar website support the 1.2.0rc1 implementation, but I think that these developer resources are out of date.

My suggested implementation in core/user_api.php would be ...

function user_get_avatar( $p_user_id, $p_size = 80 ) {
$t_email = strtolower( user_get_email( $p_user_id ) );
if( is_blank( $t_email ) ) {
$t_result = false;
} else {
$t_default_image = config_get( 'default_avatar' );
$t_size = $p_size;

    $t_use_ssl = false;
    if( isset( $_SERVER['HTTPS'] ) && ( strtolower( $_SERVER['HTTPS'] ) != 'off' ) ) {
        $t_use_ssl = true;
    }

    if( !$t_use_ssl ) {
        $t_gravatar_domain = 'http://www.gravatar.com/avatar/';
    } else {
        $t_gravatar_domain = 'https://secure.gravatar.com/avatar/';
    }

    $t_avatar_url = $t_gravatar_domain . md5( $t_email ) . '.jpg&default=' . urlencode( $t_default_image ) . '&size=' . $t_size . '&;rating=G';
    $t_result = array(
        $t_avatar_url,
        $t_size,
        $t_size,
    );
}

return $t_result;

}

sdurkin

sdurkin

2009-08-19 05:15

reporter   ~0022765

oops - there should be a ? after .jpg, not an &

atrol

atrol

2011-04-04 16:07

developer   ~0028524

dominik, you added a patch without any comments
Do we have to reopen the issue?
You changed &default to ?default
Should &size also be ?size and &rating be ?rating

dominik

dominik

2011-04-05 02:52

reporter   ~0028525

Hi Atrol

Yes the issue should be reopened (I cannot do this I get an error "access denied")...

No the path is right, it's just the first & which should be an ? to mark the start of parameters...

Sorry for the missing clarifications...

Greetings Dominik

atrol

atrol

2011-04-05 03:58

developer   ~0028526

Dominik, I am wondering because I found ?s (short form of size) and ?r (short form of rating) when looking at the link that David provided
http://en.gravatar.com/site/implement/images/

dominik

dominik

2011-04-05 04:48

reporter   ~0028527

Hi Atrol

You're right - there are two things to consider:

a) the old patch did only fix the semantically wrong url:

without patch:
http://www.gravatar.com/avatar/6edf05ec8a5816f00d1730a76b247f59&default=blabla&size=80&rating=G

with patch:
http://www.gravatar.com/avatar/6edf05ec8a5816f00d1730a76b247f59?default=blabla&size=80&rating=G

b) the new patch contains also the new short params:

with new patch:
http://www.gravatar.com/avatar/6edf05ec8a5816f00d1730a76b247f59?d=blabla&s=80&r=G

atrol

atrol

2011-04-05 06:04

developer   ~0028528

Thanks Dominik, I removed the old patch.

jreese

jreese

2011-04-05 14:21

reporter   ~0028537

Fix committed to 1.2.x and master branches.

atrol

atrol

2011-04-05 15:24

developer   ~0028538

Reminder sent to: jreese

John, IMO your commit was not the right one.
There is still &size and &rating instead of ?size and ?rating
(or the short form ?s and ?r)

I think that Dominik's patch gravatar_url_2011-05-04.patch is OK.
At least should be if the documentation is correct
http://en.gravatar.com/site/implement/images/

jreese

jreese

2011-04-05 16:40

reporter   ~0028539

Well, only the first & needed to be changed to a ?, and their documentation says that both the short and long forms are acceptable, at which point I would prefer to use the lang forms to be more explicit. The patch I committed is therefore basically comparable to what Dominik submitted.

atrol

atrol

2011-04-05 17:49

developer   ~0028541

I agree to use the long form

Still confusing:
The example http://en.gravatar.com/site/implement/images/ uses ? for all parameters, not only the first one
but http://de.gravatar.com/site/implement/images/php/ uses ? and & mixed

I played with Firebug to test the size parameter.
& is working and ? is wrong.
So one part of the gravatar documentation is wrong and your patch is OK concerning ? and &

There is also another difference to the documentation
The allowed values for parameter rating are documented lower case. We use G (suitable for display on all websites with any audience type)
I tried G and g, both work.

So your patch is also OK concerning G and g

Related Changesets

MantisBT: master 0cb72b7c

2011-03-25 06:04

dhx


Details Diff
Fix 0010850: Update Gravatar URL format to meet current standard

Gravatar's official URL syntax for loading an image is different to the
older mechanism MantisBT is still using. The official syntax is
available at:

http://en.gravatar.com/site/implement/images/
Affected Issues
0010850
mod - core/user_api.php Diff File

MantisBT: master-1.2.x cd33b412

2011-03-25 06:04

dhx


Details Diff
Fix 0010850: Update Gravatar URL format to meet current standard

Gravatar's official URL syntax for loading an image is different to the
older mechanism MantisBT is still using. The official syntax is
available at:

http://en.gravatar.com/site/implement/images/
Affected Issues
0010850
mod - core/user_api.php Diff File

MantisBT: master-1.2.x 162c0d27

2011-04-05 14:13

jreese


Details Diff
Fix 0010850: commit cd33b412 generates incorrect url Affected Issues
0010850
mod - core/user_api.php Diff File

MantisBT: master b01c7265

2011-04-05 14:13

jreese


Details Diff
Fix 0010850: commit cd33b412 generates incorrect url Affected Issues
0010850
mod - core/user_api.php Diff File