Skip to content

Instantly share code, notes, and snippets.

@wmbest2
Created Sep 25, 2009
Embed
What would you like to do?
// Replace Links with Images
if (settings.replaceLinksWithImages == 'true') {
var subset = jQuery('.postbody a');
if(settings.dontReplaceLinksSpoiler == 'true') {
subset = subset.not('.bbc-spoiler a');
}
subset.each(function() {
console.log(jQuery(this).parent());
//if((settings.dontReplaceLinksSpoiler != 'true' || jQuery(this).parents('.bbs-spoiler') != null) ) {
var match = jQuery(this).attr('href').match(/https?\:\/\/(?:[-_0-9a-zA-Z]+\.)+[a-z]{2,6}(?:\/[^/#?]+)+\.(?:jpe?g|gif|png|bmp)/);
if(match != null) {
jQuery(this).after("<img src='" + match[0] + "' />");
jQuery(this).remove();
}
//}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment