View Single Post
  #1  
Old 10th December 2014, 13:32
nicukent nicukent is offline
Senior Member
 
Join Date: Sep 2009
P2P
Posts: 40
Thumbs up U-232 V2 Modifications Image Resize Mod
Add to stdhead beside the others :
Code:
<link type='text/css' rel='stylesheet' href='image-resize/resize.css'  />
<script type='text/javascript' src='./image-resize/jquery.js'></script>
<script type='text/javascript' src='./image-resize/core-resize.js'></script>
Add to include/bbcode_functions.php :

Code:
function scale($src)
        {
            $max = 350;
            if (!isset($max, $src))
            return;
            $src = str_replace("", "%20", $src[1]);
            $info = @getimagesize($src);
            $sw = $info[0];
            $sh = $info[1];
            $addclass = false;
            $max_em = 0.06 * $max;
            if ($max < max($sw, $sh)) {
            if ($sw > $sh)
            $new = array($max_em . "em", "auto");
            if ($sw < $sh)
            $new = array("auto", $max_em . "em");
            $addclass = true;
            } else
            $new = array("auto", "auto");
            $id = mt_rand(0000, 9999);
            if ($new[0] == "auto" && $new[1] == "auto")
            $img = "<img src=\"{$src}\" border=\"0\" alt=\"\" />";
            else
            $img = "<a href=\"{$src}\" onclick=\"return false;\"><img id=\"r{$id}\" border=\"0\" alt=\"\" src=\"{$src}\" ".($addclass ? "class=\"resized\"" : "")." style=\"width:{$new[0]};height:{$new[1]};\" /></a>";
            return $img;
            }
Replace old img pregs:
Code:
//--img     
    if (stripos($s, '[img') !== false) {      
    $s = preg_replace_callback("/\[img\](http:\/\/[^\s'\"<>]+(\.(jpg|gif|png)))\[\/img\]/i", "scale", $s);
    // [img=http://www/image.gif]
    $s = preg_replace_callback("/\[img=(http:\/\/[^\s'\"<>]+(\.(gif|jpg|png)))alt=\"\"\]/i", "scale", $s);
    }
Unzip and Upload image-resize to root.
Attached Files
File Type: zip image-resize.zip (22.8 KB, 17 views)
Reply With Quote