added support for a default profile picture in case it's not defined. tweet-widget
authorhamidouk
Fri, 18 Nov 2011 11:06:55 +0100
branchtweet-widget
changeset 274 fe02d003c6c4
parent 273 c32065f5e297
child 275 a4d2dd99187b
added support for a default profile picture in case it's not defined.
src/js/site.js
src/js/widgets/tweetsWidget.js
--- a/src/js/site.js	Fri Nov 18 11:01:13 2011 +0100
+++ b/src/js/site.js	Fri Nov 18 11:06:55 2011 +0100
@@ -20,6 +20,9 @@
 
 IriSP.widgetsDefaults = {
   "PlayerWidget" : {},
-  "AnnotationsWidget": {}
+  "AnnotationsWidget": {},
+  "TweetsWidget" : {
+      default_profile_picture : "https://twimg0-a.akamaihd.net/sticky/default_profile_images/default_profile_3_bigger.png"
+  }
 };
 
--- a/src/js/widgets/tweetsWidget.js	Fri Nov 18 11:01:13 2011 +0100
+++ b/src/js/widgets/tweetsWidget.js	Fri Nov 18 11:06:55 2011 +0100
@@ -10,8 +10,14 @@
 
 IriSP.TweetsWidget.prototype.displayTweet = function(annotation) {    
     var title = annotation.content.title;
+    var img = annotation.content.img.src;
+    if (typeof(img) === "undefined" || img === "" || img === "None") {
+      img = IriSP.widgetsDefaults.TweetsWidget.default_profile_picture;
+    }
+    
     var imageMarkup = Mustache.to_html("<img src='{{src}}' alt='avatar'></img>", 
-                                       {src : annotation.content.img.src});
+                                       {src : img});
+
     this.selector.find(".Ldt-tweetContents").text(title);
     this.selector.find(".Ldt-tweetAvatar").html(imageMarkup);
     this.selector.show(50);