MyBB Community Forums

Full Version: Auto Resize Images if larger than your limit
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
@first this is not Plug-in It's just only theme editing.

This script will resize all image that wider or higher than limit, you will able to specify width and height.

How to do :
  1. Login to AdminCP and goto Templates & Style
  2. Select Templates and expand a Template you are current using.
  3. Expand Ungrouped Template. and select Header Include
  4. Add this line into somewhere you want.
    <script type="text/javascript" src="http://www.oss-zone.co.cc/scripts/js_libs.js"></script>
    and then click on Save and return to Listing
  5. expand a template you want to use this script. I reccomend to use in Showthread Template > showthread
  6. after you expanded a template. search for tag <body> and add this parameter into tag
    onLoad="AutoResize(640,480);"
    after you added. it should be something like this
    <body onLoad="AutoResize(640,480);">

so, you can specify width and height by edit value of function.
onLoad="AutoResize(<num width>,<num height>);"

after all finished. try to post a image that larger than your limit. I think it will resize automatically. and if you want to view a full size, just click on a image.



for this script. it's base on someone's script. I'm very sorry I don't know who is original author. (I saved this script into my local computer)

P.S this doesnot work

i done everything. and it doesnt resize
Bump?
Thanks its working for me
There are no file at http://www.oss-zone.co.cc/scripts/js_libs.js if somewone have the js_libs.js file please upload here. Rolleyes
This is a very old topic.

onLoad is no longer valid by the way, must be onload

Regards
i was having the same problem but was able to fixed my problem now ( credits goes to caranibieros)

This is how i did it:

add this code to global.css of your theme
Code:
.imagespost{

max-width: 500px; /* Adjust this value according to your content area size*/
    height: auto;

}

find this code at inc/class_parser.php
Code:
return "<img src=\"{$url}\" width=\"{$dimensions[0]}\" height=\"{$dimensions[1]}\" border=\"0\" alt=\"{$alt}\"{$css_align} />";
        }
        else
        {
            return "<img src=\"{$url}\" border=\"0\" alt=\"{$alt}\"{$css_align} /></div>";

change into this
Code:
return "<div id=\"imagespost\"><img src=\"{$url}\" class=\"imagespost\" width=\"{$dimensions[0]}\" height=\"{$dimensions[1]}\" border=\"0\" alt=\"{$alt}\"{$css_align} /></div>";
        }
        else
        {
            return "<div id=\"imagespost\"> <img src=\"{$url}\" class=\"imagespost\" border=\"0\" alt=\"{$alt}\"{$css_align} /></div>";

Large image will resize automatically without using GD image that make server load increase.
So i prefer using this plugin to make my save the load of my server.