워터마크를 할려구 하는데요.. 함수를 바꿀수 있는 방법은 없나요? 정보
워터마크를 할려구 하는데요.. 함수를 바꿀수 있는 방법은 없나요?본문
스킨 자료실에 있는 워터마크를 할려구 하는데요...
<span id="writeContents"><?=get_view_thumbnail_new($view['content']);?></span>
함수에서요.. content의 내용을 불러오면 되는데.. 아쉽게도 저는 지금 이미지를 직접 끌어오거든요..
<img src="<?=$g4[path]?>/photo/<?=$view[wr_link1]?>" border="0">
이런 식으로요....
그러면 <?=get_view_thumbnail_new($view['content']);?> 에서 $view['content'] 대신에 <img src="<?=$g4[path]?>/photo/<?=$view[wr_link1]?>" border="0"> 를 넣을려면 어케 해야되나요?
가능한 건가요? 가능하다면 어케 해야되는지.....
꼭 좀 부탁드립니다...
<span id="writeContents"><?=get_view_thumbnail_new($view['content']);?></span>
함수에서요.. content의 내용을 불러오면 되는데.. 아쉽게도 저는 지금 이미지를 직접 끌어오거든요..
<img src="<?=$g4[path]?>/photo/<?=$view[wr_link1]?>" border="0">
이런 식으로요....
그러면 <?=get_view_thumbnail_new($view['content']);?> 에서 $view['content'] 대신에 <img src="<?=$g4[path]?>/photo/<?=$view[wr_link1]?>" border="0"> 를 넣을려면 어케 해야되나요?
가능한 건가요? 가능하다면 어케 해야되는지.....
꼭 좀 부탁드립니다...
댓글 전체
get_view_thumbnail_new라는 함수를 보아야 답변 가능합니다
답변 진심으로 감사합니다.. 아래처럼 되어있네요...
###############################################
function get_view_thumbnail_new($contents)
{
global $g4,$board, $config;
$thumb_width = $board['bo_image_width'];
// $contents 중 img 태그 추출
$matchs = get_editor_image($contents);
if(empty($matchs))
return $contents;
for($i=0; $i<count($matchs[1]); $i++) { //echo $matchs[1][$i]."<br>";
// 이미지 path 구함
$p = parse_url($matchs[1][$i]);
if(strpos($p['path'], "/data/") != 0)
$data_path = preg_replace("/^\/.*\/data/", "/data", $p['path']);
else
$data_path = $p['path'];
$srcfile = $g4[path].$data_path;
if(is_file($srcfile)) {
// 썸네일 높이
$size = @getimagesize($srcfile);
if(empty($size))
continue;
// 원본 width가 thumb_width보다 작다면
if($size[0] <= $thumb_width && ( $thumb_width - $size[0] ) > 100 )
continue;
// Animated GIF 체크
$is_animated = false;
if($size[2] == 1) {
$is_animated = is_animated_gif($srcfile);
}
$thumb_height = round(($thumb_width * $size[1]) / $size[0]);
$filename = basename($srcfile);
$filepath = dirname($srcfile);
// 썸네일 생성
if(!$is_animated)
$thumb_file = thumbnail($filename, $filepath, $filepath, $thumb_width, $thumb_height, false);
else
$thumb_file = $filename;
$img_tag = $matchs[0][$i];
preg_match("/alt=[\"\']?([^\"\']*)[\"\']?/", $img_tag, $malt);
$alt = get_text($malt[1]);
$image = "../../..".str_replace($filename, $thumb_file, $data_path);//"../../../data/file/".$board[bo_table]."/".$thumb_file;
$argTmp = $thumbW."|".$thumbH."|".$image;
$arg = base64_encode($argTmp);
$arg = urlencode($arg);
$chgURL = "../skin/board/".$board[bo_skin]."/imgView.php?image=$arg";
$thumb_tag = '<img src="'.$chgURL.'" alt="'.$alt.'"/>';
// $img_tag에 editor 경로가 있으면 원본보기 링크 추가
if(strpos($matchs[1][$i], 'data/editor') && preg_match("/\.({$config['cf_image_extension']})$/i", $filename)) {
$imgurl = str_replace(G4_URL, "", $matchs[1][$i]);
$thumb_tag = '<a href="'.G4_BBS_URL.'/view_image.php?fn='.urlencode($imgurl).'" target="_blank" class="view_image">'.$thumb_tag.'</a>';
}
$contents = str_replace($img_tag, $thumb_tag, $contents);
}
}
return $contents;
}
###############################################
function get_view_thumbnail_new($contents)
{
global $g4,$board, $config;
$thumb_width = $board['bo_image_width'];
// $contents 중 img 태그 추출
$matchs = get_editor_image($contents);
if(empty($matchs))
return $contents;
for($i=0; $i<count($matchs[1]); $i++) { //echo $matchs[1][$i]."<br>";
// 이미지 path 구함
$p = parse_url($matchs[1][$i]);
if(strpos($p['path'], "/data/") != 0)
$data_path = preg_replace("/^\/.*\/data/", "/data", $p['path']);
else
$data_path = $p['path'];
$srcfile = $g4[path].$data_path;
if(is_file($srcfile)) {
// 썸네일 높이
$size = @getimagesize($srcfile);
if(empty($size))
continue;
// 원본 width가 thumb_width보다 작다면
if($size[0] <= $thumb_width && ( $thumb_width - $size[0] ) > 100 )
continue;
// Animated GIF 체크
$is_animated = false;
if($size[2] == 1) {
$is_animated = is_animated_gif($srcfile);
}
$thumb_height = round(($thumb_width * $size[1]) / $size[0]);
$filename = basename($srcfile);
$filepath = dirname($srcfile);
// 썸네일 생성
if(!$is_animated)
$thumb_file = thumbnail($filename, $filepath, $filepath, $thumb_width, $thumb_height, false);
else
$thumb_file = $filename;
$img_tag = $matchs[0][$i];
preg_match("/alt=[\"\']?([^\"\']*)[\"\']?/", $img_tag, $malt);
$alt = get_text($malt[1]);
$image = "../../..".str_replace($filename, $thumb_file, $data_path);//"../../../data/file/".$board[bo_table]."/".$thumb_file;
$argTmp = $thumbW."|".$thumbH."|".$image;
$arg = base64_encode($argTmp);
$arg = urlencode($arg);
$chgURL = "../skin/board/".$board[bo_skin]."/imgView.php?image=$arg";
$thumb_tag = '<img src="'.$chgURL.'" alt="'.$alt.'"/>';
// $img_tag에 editor 경로가 있으면 원본보기 링크 추가
if(strpos($matchs[1][$i], 'data/editor') && preg_match("/\.({$config['cf_image_extension']})$/i", $filename)) {
$imgurl = str_replace(G4_URL, "", $matchs[1][$i]);
$thumb_tag = '<a href="'.G4_BBS_URL.'/view_image.php?fn='.urlencode($imgurl).'" target="_blank" class="view_image">'.$thumb_tag.'</a>';
}
$contents = str_replace($img_tag, $thumb_tag, $contents);
}
}
return $contents;
}