MyBB Community Forums

Full Version: Image Resizing
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
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:
[Image: GNOME-GreenLandscape_1600x1200.jpg]
Not that I know of without of mod. But they did make it so it only ruins the post that posted a large image which is nice.Wink
I suggest this to be a 1.4 plugin!
there is already a plugin resp. a javascript which does the exact thing you mentioned.
http://mods.mybboard.net/view/image-resizer

It shouldn't be hard to use it in 1.4, just some compatibility changes tho...
Yeah, can you show the way to do this?
I can guid u to simply image resizer mod..
simply do the following in showthread template.
find {$headerinclude}
add after it
<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()">

u can change both 300 at the begin of the code to change the max width and height to suit your needs.
Edit : Template now saving

And another problem is now, I already edit my theme template (I'm using afresh orange, so I edit afresh orange theme), add the code carefully and replace all needed, the image still not resized. I already try refresh the page but just dont do
I don't think u need to chmod anything..
and it's saving as well here..
I don't know, it dont save well here, it just said that is is saved, but it is not. After doing a search at forums, I found a patch in MyBB 1.4 fixed bug, apply a fix, and template is saving. And another problem is now, I already edit my theme template (I'm using afresh orange, so I edit afresh orange theme), add the code carefully and replace all needed, the image still not resized. I already try refresh the page but just dont do
Or:

OPEN inc/class_parser.php

Search:
return "<img src=\"{$url}\" border=\"0\" alt=\"{$alt}\"{$css_align} />"; 

Replace:
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} />";

Bye
Pages: 1 2