회원 페이지에서 외부 이미지의 가로 크기를 리사이징 하는 방법
본문
skin/member/basic/register_form.skin.php 에 보면 자기소개를 하는 란이 있는데요,
여기에 쓴 자기 소개가 게시물을 클릭했을 때 보이도록 하기 위해 skin/board/basic/view.skin.php에
다음과 같은 코드를 넣었습니다.
-------------------------------------------------------------
<!-- 자기소개 출력 -->
<?
// 자기소개 데이터
$profile=get_member($view[mb_id], "mb_profile");
<?
// 자기소개 데이터
$profile=get_member($view[mb_id], "mb_profile");
// 프로필이 있을 때
if($profile['mb_profile']){
echo $profile['mb_profile'];
} else {
echo " ";
}
?>
?>
-------------------------------------------------------------
문제는, 자기 소개란에 img 태그를 사용해서 외부 이미지를 불러온 회원의 경우인데요,
이 외부 이미지 크기가 게시판 가로 길이보다 클 경우 게시판 가로 길이가 전체적으로 늘어나버립니다.
예를 들어, 지정한 게시판 가로 길이가 600 (table width="600") 인데
불러온 외부 이미지의 원본 가로 크기가 1000이면 게시판 가로 길이가 1000으로 나와버립니다.
외부 이미지의 가로 길이를 게시판의 크기에 강제로 맞출 수 있는 방법이 없을까요?
답변 2
이미지가 하나만 있다는 가정하에..
// 자기소개 데이터
$profile=get_member($view[mb_id], "mb_profile");
?>
<div id='prof'><?=$profile['mb_profile']?></div>
<script>
img_width=$board[bo_image_width];
$(window).load(function (){
ww=$('#prof img').attr('width'); hh = $('#prof img').attr('height');
<script>
img_width=$board[bo_image_width];
$(window).load(function (){
ww=$('#prof img').attr('width'); hh = $('#prof img').attr('height');
if(ww>img_width){
newhh= img_width * hh / ww;
$('#prof img').attr({'width' : img_width, 'height':newhh});
});
</script>
newhh= img_width * hh / ww;
$('#prof img').attr({'width' : img_width, 'height':newhh});
});
</script>
echo '<div class="profile">'.$profile['mb_profile'].'</div'>;
<style>
.profile img { max-width: 600px; }
</style>
답변을 작성하시기 전에 로그인 해주세요.