Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Propane caveatPatchor.js hack to display data:image urls inline as images
if (displayDataURLImages) {
Campfire.DataImageURLExpander = Class.create({
initialize: function(chat) {
this.chat = chat;
var messages = this.chat.transcript.messages;
for (var i = 0; i < messages.length; i++) {
this.detectDataURLImage(messages[i]);
}
},
detectDataURLImage: function(message) {
if (!message.pending() && message.kind === 'text') {
var links = message.bodyElement().select('a');
if (links.length > 0) {
return;
}
var bodyContent = message.bodyElement().textContent;
var match = bodyContent.match(/^data:image\/\w+;base64/);
if (!match) return;
message.resize((function() {
message.bodyCell.insert({bottom: '<div style="width:100%; margin-top:5px; padding-top: 5px; border-top:1px dotted #ccc;"><img src="'+bodyContent+'" onload="$dispatch(&quot;inlineImageLoaded&quot;, this)" onerror="$dispatch(&quot;inlineImageLoadFailed&quot;, this)" /></div>'});
}).bind(this));
}
},
onMessagesInsertedBeforeDisplay: function(messages) {
for (var i = 0; i < messages.length; i++) {
this.detectDataURLImage(messages[i]);
}
},
onMessageAccepted: function(message, messageID) {
this.detectDataURLImage(message);
}
});
Campfire.Responders.push("DataImageURLExpander");
window.chat.installPropaneResponder("DataImageURLExpander", "dataimageurlexpander");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.