업로드된 이미지 자바스크립트 사용하지 않고 리사이즈 하기
엄밀히 말하자면 리사이즈라고 할 수는 없습니다.
폭이 보드 설정값보다 크면 작게 줄여주는건데 자바스크립트를 사용하죠... (원래는)
그래서 다 로딩되고 나서 줄어드는데 아얘 속성값을 줘서 미리부터
작게 나오도록 조정해봤습니다.
lib/common.lib.php 파일중 일부입니다.
// 파일을 보이게 하는 링크 (이미지, 플래쉬, 동영상)
function view_file_link($file, $width, $height, $content='')
{
global $config, $board;
global $g4;
if (!$file) return;
$org_width = $width;
$org_height = $height;
if(!$width) {
$width = $board['bo_image_width'];
$height = $board['bo_image_width'] / 4 * 3;
}
elseif ($width > $board['bo_image_width']) {
$image_height = (float)$width / $height;
$width = $board['bo_image_width'];
$height = (int)($width / $image_height);
}
$file = "{$g4['path']}/data/file/{$board['bo_table']}/" . urlencode($file);
if (preg_match("/\.({$config['cf_image_extension']})$/i", $file))
return "<img src=\"{$file}\" width=\"{$width}\" height=\"{$height}\" onclick=\"this.tmp_width={$org_width};this.tmp_height={$org_height};image_window(this);\" style=\"cursor:pointer;\" title=\"{$content}\" alt=\"{$content}\" />";
else if (preg_match("/\.({$config['cf_flash_extension']})$/i", $file))
return "<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0\" width=\"{$width}\" height=\"{$height}\"><param name=\"movie\" value=\"{$file}\" /><param name=\"quality\" value=\"high\" /><!-- Hixie method --><!--[if !IE]><--><object type=\"application/x-shockwave-flash\" data=\"{$file}\" width=\"{$width}\" height=\"{$height}\"><param name=\"movie\" value=\"{$file}\" /><param name=\"quality\" value=\"high\" /></object><!--><![endif]--></object>";
else if (preg_match("/\.({$config['cf_movie_extension']})$/i", $file)) {
return "<object classid=\"clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95\" id=\"MediaPlayer\"><param name=\"Filename\" value=\"{$file}\"><param name=\"AutoStart\" value=\"0\"><param name=\"ShowAudioControls\" value=\"true\"><param name=\"ShowPositionControls\" value=\"true\"><param name=\"ShowStatusBar\" value=\"true\"><param name=\"ShowTracker\" value=\"true\"><param name=\"ShowControls\" value=\"true\"><param name=\"loop\" value=\"0\"><param name=\"ShowDisplay\" value=\"false\"><!-- Hixie method --><!--[if !IE]><--><object type=\"application/x-mplayer2\" data=\"{$file}\" width=\"{$width}\" height=\"{$height}\"><param name=\"Filename\" value=\"{$file}\"><param name=\"AutoStart\" value=\"0\"><param name=\"ShowAudioControls\" value=\"true\"><param name=\"ShowPositionControls\" value=\"true\"><param name=\"ShowStatusBar\" value=\"true\"><param name=\"ShowTracker\" value=\"true\"><param name=\"ShowControls\" value=\"true\"><param name=\"loop\" value=\"0\"><param name=\"ShowDisplay\" value=\"false\"></object><!--><![endif]--></object>";
}
}
덧붙여서 플래시와 동영상의 embed를 object로 바꿔봤습니다.
(코드를 좀 많이 손댔더니 어디라고 콕 집어 말하기 곤란하네요...)
폭이 보드 설정값보다 크면 작게 줄여주는건데 자바스크립트를 사용하죠... (원래는)
그래서 다 로딩되고 나서 줄어드는데 아얘 속성값을 줘서 미리부터
작게 나오도록 조정해봤습니다.
lib/common.lib.php 파일중 일부입니다.
// 파일을 보이게 하는 링크 (이미지, 플래쉬, 동영상)
function view_file_link($file, $width, $height, $content='')
{
global $config, $board;
global $g4;
if (!$file) return;
$org_width = $width;
$org_height = $height;
if(!$width) {
$width = $board['bo_image_width'];
$height = $board['bo_image_width'] / 4 * 3;
}
elseif ($width > $board['bo_image_width']) {
$image_height = (float)$width / $height;
$width = $board['bo_image_width'];
$height = (int)($width / $image_height);
}
$file = "{$g4['path']}/data/file/{$board['bo_table']}/" . urlencode($file);
if (preg_match("/\.({$config['cf_image_extension']})$/i", $file))
return "<img src=\"{$file}\" width=\"{$width}\" height=\"{$height}\" onclick=\"this.tmp_width={$org_width};this.tmp_height={$org_height};image_window(this);\" style=\"cursor:pointer;\" title=\"{$content}\" alt=\"{$content}\" />";
else if (preg_match("/\.({$config['cf_flash_extension']})$/i", $file))
return "<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0\" width=\"{$width}\" height=\"{$height}\"><param name=\"movie\" value=\"{$file}\" /><param name=\"quality\" value=\"high\" /><!-- Hixie method --><!--[if !IE]><--><object type=\"application/x-shockwave-flash\" data=\"{$file}\" width=\"{$width}\" height=\"{$height}\"><param name=\"movie\" value=\"{$file}\" /><param name=\"quality\" value=\"high\" /></object><!--><![endif]--></object>";
else if (preg_match("/\.({$config['cf_movie_extension']})$/i", $file)) {
return "<object classid=\"clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95\" id=\"MediaPlayer\"><param name=\"Filename\" value=\"{$file}\"><param name=\"AutoStart\" value=\"0\"><param name=\"ShowAudioControls\" value=\"true\"><param name=\"ShowPositionControls\" value=\"true\"><param name=\"ShowStatusBar\" value=\"true\"><param name=\"ShowTracker\" value=\"true\"><param name=\"ShowControls\" value=\"true\"><param name=\"loop\" value=\"0\"><param name=\"ShowDisplay\" value=\"false\"><!-- Hixie method --><!--[if !IE]><--><object type=\"application/x-mplayer2\" data=\"{$file}\" width=\"{$width}\" height=\"{$height}\"><param name=\"Filename\" value=\"{$file}\"><param name=\"AutoStart\" value=\"0\"><param name=\"ShowAudioControls\" value=\"true\"><param name=\"ShowPositionControls\" value=\"true\"><param name=\"ShowStatusBar\" value=\"true\"><param name=\"ShowTracker\" value=\"true\"><param name=\"ShowControls\" value=\"true\"><param name=\"loop\" value=\"0\"><param name=\"ShowDisplay\" value=\"false\"></object><!--><![endif]--></object>";
}
}
덧붙여서 플래시와 동영상의 embed를 object로 바꿔봤습니다.
(코드를 좀 많이 손댔더니 어디라고 콕 집어 말하기 곤란하네요...)
댓글 6개
rosper
20년 전
위의 return 라인에 히어닥을 쓰면 좀더 깔끔해지지 않을까 생각해봅니다.
팁감사합니다. :)
팁감사합니다. :)
사랑과우정
20년 전
좋은 팁 감사합니다... 일단 적용했습니다.. 테스트는 나중에..ㅋㅋ
20년 전
감사해요 +ㅁ+
19년 전
덕분에 쉽게 해결~^^ 고맙습니다~
19년 전
와우~ 감사합니다~
18년 전
^^* 정말 감사드립니다...^^*
게시판 목록
그누4 팁자료실
그누보드4와 관련된 팁을 여러분들과 함께 공유하세요.
나누면 즐거움이 커집니다.
나누면 즐거움이 커집니다.
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 89 |
g6man
|
20년 전 | 6187 | |
| 88 | 20년 전 | 6756 | ||
| 87 |
g6man
|
20년 전 | 4142 | |
| 86 | 20년 전 | 5256 | ||
| 85 | 20년 전 | 6136 | ||
| 84 | 20년 전 | 18355 | ||
| 83 | 20년 전 | 7369 | ||
| 82 | 20년 전 | 7456 | ||
| 81 | 20년 전 | 5364 | ||
| 80 | 20년 전 | 5051 | ||
| 79 |
황제.com
|
20년 전 | 4453 | |
| 78 | 20년 전 | 4044 | ||
| 77 | 20년 전 | 6018 | ||
| 76 |
innoX
|
20년 전 | 6066 | |
| 75 |
아꽈
|
20년 전 | 12602 | |
| 74 | 20년 전 | 3341 | ||
| 73 | 20년 전 | 7179 | ||
| 72 |
rosper
|
20년 전 | 3308 | |
| 71 |
rosper
|
20년 전 | 5248 | |
| 70 | 20년 전 | 3855 |
정보수정란의 이미지 변경 및 회원탈퇴 추가 [31]
아꽈
•
20년 전
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기