
Link to gravatar image is generated completely on client-side and no longer included into user or record objects. Added libs: * JS MD5 (BSD license) * JS jQuery.gravatar (WTFPL license), changed Removed libs: * Flask.Gravatar Closes bug 1320242 Change-Id: Iee08dc845c162a3ccb97d176997df31a6e7b3c63
52 lines
1.6 KiB
JavaScript
52 lines
1.6 KiB
JavaScript
/*
|
|
* jQuery.gravatar 1.0.1 (2009-01-08)
|
|
*
|
|
* Written by Zach Leatherman
|
|
* http://zachleat.com
|
|
*
|
|
* Licensed under the WTFPL (http://sam.zoy.org/wtfpl/)
|
|
*
|
|
* Requires jQuery http://jquery.com (1.2.6 at time of release)
|
|
* Requires http://pajhome.org.uk/crypt/md5/md5.js
|
|
*/
|
|
|
|
(function($)
|
|
{
|
|
$.gravatarImageURI = function(emailAddress, overrides)
|
|
{
|
|
var options = $.extend({
|
|
// Defaults are not hardcoded here in case gravatar changes them on their end.
|
|
// integer size: between 1 and 512, default 80 (in pixels)
|
|
size: '',
|
|
// rating: g (default), pg, r, x
|
|
rating: '',
|
|
// url to define a default image (can also be one of: identicon, monsterid, wavatar)
|
|
image: '',
|
|
// secure
|
|
secure: false,
|
|
// support css on img element
|
|
classes: ''
|
|
}, overrides);
|
|
|
|
var baseUrl = options.secure ? 'https://secure.gravatar.com/avatar/' : 'http://www.gravatar.com/avatar/';
|
|
|
|
return baseUrl +
|
|
hex_md5(emailAddress) +
|
|
'.jpg?' +
|
|
(options.size ? 's=' + options.size + '&' : '') +
|
|
(options.rating ? 'r=' + options.rating + '&' : '') +
|
|
(options.image ? 'd=' + encodeURIComponent(options.image) : '');
|
|
};
|
|
|
|
$.gravatar = function(emailAddress, overrides)
|
|
{
|
|
return $('<img src="' + $.gravatarImageURI(emailAddress, overrides) +
|
|
'"' +
|
|
(options.classes ? ' class="' + options.classes + '"' : '') +
|
|
' />').bind('error', function()
|
|
{
|
|
$(this).remove();
|
|
});
|
|
};
|
|
})(jQuery);
|