? .:>Automatically picture resizing<:. ?

e107 CMS » Forums » Miscellaneous » General Discussion << Previous thread | Next thread >>
*MartiX
Aug 19 2010, 12:24PM
Registered Member #58160
Joined: Aug 07 2010, 10:51AM
Location: Lithuania, Kaunas
Posts: 14
Hey guys, I'm new in e107 and i want to resize images in site pages and forum. Is it easy? How can I do that?
[ Edited Aug 19 2010, 02:01PM ]
Go to top
C6Dave
Aug 19 2010, 02:40PM
  • e107 Site administrator
  • e107 Support Team Leader
Registered Member #9506
Joined: Jul 31 2004, 12:57AM
Location: North East UK
Posts: 12343
Onsite or offsite hosted?

Read: [-link-]

If you search the forums there are lots of other threads as well [-link-]
Go to top
Website
*MartiX
Aug 20 2010, 11:13AM
Registered Member #58160
Joined: Aug 07 2010, 10:51AM
Location: Lithuania, Kaunas
Posts: 14
I read all these topics. When I add this :

global $pref;
if (preg_match("#\.php\?.*#",$code_text)){return "";}
global $IMAGES_DIRECTORY, $FILES_DIRECTORY, $e107;
$search = array('"', '{E_IMAGE}', '{E_FILE}');
', $e107->base_path.$IMAGES_DIRECTORY, $e107->base_path.$FILES_DIRECTORY);
$code_text = str_replace($search, $replace, $code_text);
unset($imgParms);
$imgParms['class']="bbcode";
$imgParms['alt']='';
$imgParms['style']="vertical-align: middle; border:0";

$code_text = $tp -> toAttribute($code_text);

if($parm) {
$parm = preg_replace('#one<i></i>rror *=#i','',$parm);
$parm = str_replace("amp;", "&", $parm);
parse_str($parm,$tmp);
foreach($tmp as $p => $v) {
$imgParms[$p]=$v;
}
}
$parmStr="";
foreach($imgParms as $k => $v) {
$parmStr .= $tp -> toAttribute($k)."='".$tp -> toAttribute($v)."' ";
}


if(file_exists(e_IMAGE."newspost_images/".$code_text))
{
$code_text = e_IMAGE."newspost_images/".$code_text;
}

// add
if (!function_exists('resizeme')) {
function resizeme ($code_text) {
$size = getimagesize($code_text);
if ($size !== false) {
$w = $size[0];
$h = $size[1];
$maxW = 400; // change max width here
if ($w > $maxW) {
$h = intval($h / ($w/$maxW));
$w = $maxW;
$parmStr .= " width='$w' height='$h'";
return $parmStr;
}
}
return false;
}
}
$resizeme = resizeme ($code_text);
$resizeme_prefix ="";
$resizeme_postfix="";
if ($resizeme != false) {
$resizeme_prefix .= "<a href='$code_text' rel='external'>";
$parmStr .= $resizeme;
$resizeme_postfix .= "</a>";
}
// end add


if (!$postID) {
return "$resizeme_prefix<img src='".$code_text."' {$parmStr} />$resizeme_postfix"; //add
} else {
if(strstr($postID,'class:')) {
$uc = substr($postID,6);
}
if ($pref['image_post']) {
if(!isset($uc) || ($uc == '')) {
if (!function_exists('e107_userGetuserclass')) {
require_once(e_HANDLER.'user_func.php');
}
$uc = e107_userGetuserclass($postID);
}
if (check_class($pref['image_post_class'],$uc)) {
return "$resizeme_prefix<img src='".$code_text."' {$parmStr} />$resizeme_postfix"; // add
}
else
{
return ($pref['image_post_disabled_method'] ? "[ image disabled ]" : "Image: $code_text");
}
}
else
{
if ($pref['image_post_disabled_method']) {
return '[ image disabled ]';
} else {
return "Image: $code_text";
}
}
}


In FBOX which is installed in my site, i get error :

Parse error: syntax error, unexpected T_CLASS in /home/xevil/domains/spectacular.lt/public_html/e107_handlers/bbcode_handler.php(298) : eval()'d code on line 8

This is my original img.bb
:
global $pref;
if (trim($code_text) == "") return ""; 						// Do nothing on empty file
if (preg_match("#\.php\?.*#",$code_text)){return "";}
global $IMAGES_DIRECTORY, $FILES_DIRECTORY, $e107;
$search = array('"', '{E_IMAGE}', '{E_FILE}', 'http://e107.org/e107_images/', 'http://e107.org/e107_files/');
$replace = array(''', $e107->base_path.$IMAGES_DIRECTORY, $e107->base_path.$FILES_DIRECTORY, $e107->base_path.$IMAGES_DIRECTORY, $e107->base_path.$FILES_DIRECTORY);
$code_text = str_replace($search, $replace, $code_text);
unset($imgParms);
$imgParms['class']="bbcode";  
$imgParms['alt']='';

$code_text = $tp -> toAttribute($code_text);

if($parm)
{
    $parm = preg_replace('#one<i></i>rror *=#i','',$parm);
    $parm = str_replace("amp;", "&", $parm);
    parse_str($parm,$tmp);
    foreach($tmp as $p => $v)
	{
        $imgParms[$p]=$v;
    }
}
$parmStr="";
foreach($imgParms as $k => $v)
{
    $parmStr .= $tp -> toAttribute($k)."='".$tp -> toAttribute($v)."' ";
}

// Only look for file if not a url - suspected bug in PHP 5.2.5 on XP
if((strpos($code_text,'../') === FALSE) && (strpos($code_text,'://') === FALSE) && file_exists(e_IMAGE."newspost_images/".$code_text))
{
    $code_text = e_IMAGE_ABS."newspost_images/".$code_text;
}
if (varsettrue($pref['image_post']) && check_class($pref['image_post_class']))
{
	return "<img src='".$code_text."' {$parmStr} />";
}
switch ($pref['image_post_disabled_method'])
{
	case '1' :
		return CORE_LAN17;
	case '2' :
		return '';
}
return CORE_LAN18.$code_text;



But... If i'll try this

if (function_exists("getimagesize")) {
$size = getimagesize($code_text);
if ($size !== false) {
$w = $size[0];
$h = $size[1];
$maxW = 595;
if ($w > $maxW) {
$h = intval($h / ($w/$maxW));
$w = $maxW;
}
$parmStr .= " width='$w' height='$h'";
}
}
It should wokr?

Yes, it works... but. it laggs the site now :{ one page loads in 3 mins.


SOMEONE HELP?? THIS SITE IS DEAD.
[ Edited Aug 20 2010, 11:24PM ]
Go to top
 

Jump:     Back to top

Syndicate this thread: rss 0.92 Syndicate this thread: rss 2.0 Syndicate this thread: RDF
Powered by e107 Forum System