With a little side of applesauce...

Tuesday, December 18, 2012

Add custom thumbnail instead of pagepeeker preview

(copied from my feature request on the timeline.js Google Group)

Hi all,

I am implementing timeline.js with a class interactive here at MY, and found that pagepeeker couldn't access our protected videos, (through the library). I created a work-around that allows you to include a custom clickable thumbnail in the data.json.

synopsis: checks for 'thumbnail' key in asset struct. If asset.thumbnail != null && asset.thumbnail != ''; then show thumbnail. Else, show pagepeeker thumb.

Here is the updated json:

    "asset":
    {
     "media":"http://ezproxy.library.my.edu/login?url=http://myhostedfilms.com",
     "credit":"",
     "caption":"",
     "thumbnail":""
    }


Here is the patch:

--- timeline.js.orig 2012-12-18 10:32:32.000000000 -0800
+++ timeline.js 2012-12-18 11:10:53.000000000 -0800
@@ -4050,17 +4050,23 @@
    
    create: function(m) {
     trace("WEB THUMB CREATE");
-    //http://pagepeeker.com/t/{size}/{url}
+                            if (m.thumbnail != null && m.thumbnail != "") {
+
+                                thumb_url=m.thumbnail;
+                                VMM.attachElement("#" + m.uid, "");
+    VMM.attachElement("#" + m.uid + "_thumb", "");
+                            } else {
+                                //http://pagepeeker.com/t/{size}/{url}
     //http://api.snapito.com/free/lc?url=
     
     var thumb_url = "http://pagepeeker.com/t/";
-     url   = m.id.replace("http://", "");//.split("/")[0];
-     
+    url   = m.id.replace("http://", "");//.split("/")[0];
     // Main Image
     VMM.attachElement("#" + m.uid, "");
     
     // Thumb
     VMM.attachElement("#" + m.uid + "_thumb", "");
+                            }
    },
    
    pushQue: function() {
@@ -4190,10 +4196,11 @@
    
    if (data.media != null && data.media != "") {
     var mediaElem = "", captionElem = "", creditElem = "", _id = "", isTextMedia = false, m;
-    
+
     m = VMM.MediaType(data.media); //returns an object with .type and .id
     m.uid = uid;
     _valid = true;
+                            
     
    // CREDIT
     if (data.credit != null && data.credit != "") {
@@ -4203,6 +4210,10 @@
     if (data.caption != null && data.caption != "") {
      captionElem   = "
" + VMM.Util.linkify_with_twitter(data.caption, "_blank") + "
";
     }
+   // CUSTOM THUMBNAIL
+    if (data.thumbnail != null && data.thumbnail != "") {
+                                    m.thumbnail = data.thumbnail;
+    }
    // IMAGE
     if (m.type    == "image") {
      if (m.id.match("https://")) {


Thanks for the great product!

speeves

No comments: