/*
* 處理圖片的尺寸
* @param content
*/
public function editImagesSize($content){
$images = $this->getimages(ubb2html($content));//獲取帖子內容中的圖片
if($images){
foreach($images as $key => $value){
$arr = getimagesize($value[1]);
if($arr[0] > 700){
$imgWidth = 700;
$imgHeight=($arr[1]/$arr[0])*$imgWidth;
$Think_img = new ThinkImage(THINKIMAGE_GD);
$photo_url = preg_replace("/\//", "\/", CFG_PHOTO_URL);
$pattern = "/" . $photo_url . "(.*)/";
$replacement = PHOTO_ROOT . "$1";
$img_path = preg_replace($pattern,$replacement,$value[1]);
$Think_img->open($img_path)->thumb($imgWidth,$imgHeight, 1);
unlink($img_path);
$Think_img->save($img_path);
}
}
}
return preg_replace("/\[img\]([\w|\/|\:|\.]+)\[\/img\]/", "[img]$1?" . rand(1000,9999) . "[/img]", $content);
}