Created
July 9, 2011 20:18
-
-
Save ayosec/1073923 to your computer and use it in GitHub Desktop.
Show images in tweets.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copy this to ~/.js/twitter.com.js | |
* Tested with dotjs for Firefox | |
* | |
* http://codingfulness.tumblr.com/post/7476823732/inline-images-twitter | |
* | |
* Public Domain Licence | |
*/ | |
$(function() { | |
$(window).bind("DOMNodeInserted", function(event) { | |
var target = $(event.target); | |
if(target.data("item-type") === "tweet") { | |
if(target.data("expand-images-done") === "ready") | |
return; | |
target.data("expand-images-done", "ready"); | |
var target_width = target.width(); | |
target.find("a.twitter-timeline-link").each(function() { | |
var url = String.prototype.toString.call(this.href); | |
if(url.indexOf("http://t.co/") === 0 && this.title) | |
url = this.title; | |
unsafeWindow.twttr.media.resolveImageUrl(url, 300, { | |
success: function(url) { | |
$("<img>", { | |
src: url, | |
width: target_width - 100, | |
}). | |
css("margin-left", "50px"). | |
appendTo(target); | |
}, | |
error: function() { /* ignored */ } | |
}); | |
}) | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment