[gitg] Correctly fallback on robohash with size



commit 78d6a16ddf22654e090224d0f52de33007605215
Author: Jesse van den Kieboom <jesse vandenkieboom epfl ch>
Date:   Tue Oct 16 20:27:02 2012 +0200

    Correctly fallback on robohash with size

 libgitg-gtk/resources/base.js |   16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)
---
diff --git a/libgitg-gtk/resources/base.js b/libgitg-gtk/resources/base.js
index 51aa6d8..b201545 100644
--- a/libgitg-gtk/resources/base.js
+++ b/libgitg-gtk/resources/base.js
@@ -286,9 +286,21 @@ addEventListener('DOMContentLoaded', function () {
 		'.avatar': function (e) {
 			var h = this.author.email_md5;
 
-			var robo = 'http://robohash.org/' + h + '.png?size=80x80';
+			var loader = $('<img/>');
 
-			e.attr('src', 'http://www.gravatar.com/avatar/' + h + '?d=' + encodeURIComponent(robo) + '&s=50');
+			loader.on('error', function () {
+				var robosrc = 'http://robohash.org/' + h + '.png?size=50x50';
+
+				e.attr('src', robosrc);
+			});
+
+			var gravatar = 'http://www.gravatar.com/avatar/' + h + '?d=404&s=50';
+
+			loader.on('load', function () {
+				e.attr('src', gravatar);
+			});
+
+			loader.attr('src', gravatar);
 		},
 	});
 }, false);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]