2008-07-13, 09:42 PM
Is there any way in myBB 1.4 that I can have a user-posted image automatically resized so that it doesn't mess with the layout of the page?
Example:
Example:
<script type="text/javascript">
<!--
function ResizeThem()
{
var maxheight = 300;
var maxwidth = 300;
var imgs = document.getElementsByTagName("img");
for ( var p = 0; p < imgs.length; p++ )
{
if ( imgs[p].getAttribute("alt") == "" )
{
var w = parseInt( imgs[p].width );
var h = parseInt( imgs[p].height );
if ( w > maxwidth )
{
imgs[p].style.cursor = "pointer";
imgs[p].onclick = function( )
{
var iw = window.open ( this.src, 'ImageViewer','resizable=1' );
iw.focus();
};
h = ( maxwidth / w ) * h;
w = maxwidth;
imgs[p].height = h;
imgs[p].width = w;
}
if ( h > maxheight )
{
imgs[p].style.cursor="pointer";
imgs[p].onclick = function( )
{
var iw = window.open ( this.src, 'ImageViewer','resizable=1' );
iw.focus( );
};
imgs[p].width = ( maxheight / h ) * w;
imgs[p].height = maxheight;
}
}
}
}
// -->
</script>
find <body> replace with <body onload="ResizeThem()">return "<img src=\"{$url}\" border=\"0\" alt=\"{$alt}\"{$css_align} />";
return "<img src=\"{$url}\" onload=\"if(this.width > 800) {this.width=800} if(this.height > 600) {this.height=600}\" border=\"0\" alt=\"{$alt}\"{$css_align} />";