Skip to content

Instantly share code, notes, and snippets.

@wmbest2
Created Sep 25, 2009
Embed
What would you like to do?
// Replace inline Images with Links
if (settings.replaceImagesWithLinks == 'true') {
jQuery('.postbody img').each(function() {
var source = jQuery(this).attr('src');
jQuery(this).after("<a href='" + source + "'>" + source + "</a>");
jQuery(this).remove();
});
}
// Replace Links with Images
if (settings.replaceLinksWithImages == 'true') {
jQuery('.postbody a').each(function() {
console.log(jQuery(this).parents());
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