업로드된 이미지 자바스크립트 사용하지 않고 리사이즈 하기 > 그누4 팁자료실

그누4 팁자료실

그누보드4와 관련된 팁을 여러분들과 함께 공유하세요.
나누면 즐거움이 커집니다.

업로드된 이미지 자바스크립트 사용하지 않고 리사이즈 하기 정보

업로드된 이미지 자바스크립트 사용하지 않고 리사이즈 하기

본문

엄밀히 말하자면 리사이즈라고 할 수는 없습니다.
폭이 보드 설정값보다 크면 작게 줄여주는건데 자바스크립트를 사용하죠... (원래는)
그래서 다 로딩되고 나서 줄어드는데 아얘 속성값을 줘서 미리부터
작게 나오도록 조정해봤습니다.

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로 바꿔봤습니다.
(코드를 좀 많이 손댔더니 어디라고 콕 집어 말하기 곤란하네요...)
추천
0
  • 복사

댓글 6개

© SIRSOFT
현재 페이지 제일 처음으로