Skip to content

Instantly share code, notes, and snippets.

@wmbest2
Created September 25, 2009 15:54
Show Gist options
  • Save wmbest2/193659 to your computer and use it in GitHub Desktop.
Save wmbest2/193659 to your computer and use it in GitHub Desktop.
// 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