//轉換圖片地址 function urlFormat($url){ if(empty($url)){ return Config("imgUrl"); //return ""; } $strpos = strpos($url, "http"); if($strpos === false){ return Config("imgUrl").$url; }else{ return $url; } } /** * 圖片地址替換成壓縮URL * @param string $content 內容 */ function get_img_thumb_url($content="") { $pregRule = "/<[img|IMG].*?src=[\'|\"](.*?(?:[\.jpg|\.jpeg|\.png|\.gif|\.bmp]))[\'|\"].*?[\/]?>/"; $content = preg_replace($pregRule, '<img src="'.Config("imgUrl").'${1}" style="max-width:100%">', $content); return $content; }