* 적용함수 * preg_match_all() * preg_match() * getimagesize() * filesize() function appImages($text){ global $_fileDir; global $_fileUrl; $img1 = array(); $img_cnt = preg_match_all("/<img[^>]*src=[\"']?([^>\"']+)[\"']?[^>]*>/i", $text, $match); //이미지파일 html 추출 if($img_cnt > 0) { for ($i=0; $i<$img_cnt; $i++) { $img1[] = $match[0][$i]; $img2[] = $match[1][$i]; } } $html = ""; if(count($img1) > 1){ for($i=0; $i<@count($img1); $i++) { $img1_text = $img1[$i]; preg_match("/<img[^>]*src=[\"']?([^>\"']+)[\"']?[^>]*>/i", $img1_text, $match_url); //이미지 경로만 추출 $img_url = trim($match_url[1]); //$img_dir = str_replace("http://file.domain.com/", "/home/domain/file/", $img_url); $img_dir = str_replace($_fileUrl, $_fileDir, $img_url); if(is_file($img_dir)) { $img_size = getimagesize($img_dir); $file_size = filesize($img_dir); $file_size = $file_size/1024; $html .= "삭제 "; $html .= "보기 "; $html .= "".$img_url." "; $html .= "(".$file_size."KB, ".$img_size[0]."x".$img_size[1].") "; } } } return $html; }
'PHP' 카테고리의 다른 글
(함수) shuffle() & str_shuffle() - 랜덤함수 (0) | 2014.02.04 |
---|---|
(함수) date() (0) | 2013.05.30 |
(함수) PHP5.3 Debug (0) | 2012.11.05 |
(함수) JS, CSS 소스 압축(줄바꿈, 들여쓰기, 주석 제거) (0) | 2012.10.12 |
(합수)define() - 해당페이지 직접 접근 제어 (0) | 2012.08.06 |