|
Resize large [IMG] images and link them to original
This modification is in the archives.
This mod should resize [IMG] images wider than 'max_width' and link them to their original size. Not very well tested, i'm hoping for some feedback/suggestions. I have tested in firefox/IE latest versions and it seems to work fine. Should be a pretty quick install.
INSTALL: 1) Edit /includes/class_bbcode.php around line 1879 for me. Look for: Code:
return '<img src="' . $link . '" border="0" alt="" />'; Code:
return '<img src="' . $link . '" border="0" alt="" class="img_tag" />'; Code:
<if condition="THIS_SCRIPT == 'showthread'">
<script type="text/javascript">
max_width = 700;
if(document.documentElement.outerHTML == null) {
HTMLElement.prototype.__defineSetter__("outerHTML", function (sHTML) {
var r = this.ownerDocument.createRange();
r.setStartBefore(this);
var df = r.createContextualFragment(sHTML);
this.parentNode.replaceChild(df, this);
});
}
function resizeImages() {
for(var i=0; i<document.images.length; i++)
{
var img = document.images[i];
if(img.className == "img_tag") {
if(img.width > max_width) {
var strNewHTML = '<a href="' + img.src + '" target="_blank"><img width = "' + max_width + '" src="' + img.src + '" border=0 alt="" /></a>';
img.outerHTML = strNewHTML;
}
}
}
}
if (window.addEventListener) {
window.addEventListener('load', resizeImages, false);
} else if (window.attachEvent) {
window.attachEvent('onload', resizeImages);
} else {
window.onload = resizeImages;
}
</script>
</if>
Download No files for download. |
|||||||||
Similar Mods
| Show Thread Enhancements Auto Resize large images in an IMG tag | vBulletin 3.7 Add-ons |
| Forum Display Enhancements Auto Resize large images in an IMG tag | vBulletin 3.6 Add-ons |
| Auto Resize large images in an IMG tag | vBulletin 3.5 Add-ons |