이미지 비교 게시판 > 그누보드5 스킨

그누보드5 스킨

좋은 댓글과 좋아요는 제작자에게 큰힘이 됩니다.

이미지 비교 게시판 정보

게시판 이미지 비교 게시판

첨부파일

image_compare.zip (31.0K) 23회 다운로드 2022-11-01 03:33:19 포인트 차감10
테스트한 버전5.4.22
호환 가능 버전5.3 이상 가능할겁니다

본문

 

두개의 사진을 슬라이드로 이동하면서 비교해볼 수 있는 게시판입니다.

basic게시판을 커스텀했습니다.

원소스: https://www.w3schools.com/howto/howto_js_image_comparison.asp

여분필드를 3개 사용하였습니다.

압축을 풀면 image_compare라는 폴더가 나옵니다.

이것을 그누보드 순정기준 skin/board/image_compare가 되게 업로드해줍니다.

pc용입니다. 모바일용은 테스트과정에서 크기가 안맞는등 오류가 발생해서 차후에 보완하겠습니다.

 

wr_1: 슬리이드의 위치 버튼의 위치를 숫자로 입력합니다 wr_1: 1:오른쪽, 2:가운데, 2~500사이:왼쪽에서 가운데 사이 적당히 위치

wr_2: 첫째 이미지 예: http://example.com/images/suzy1.png

wr_3: 둘째 이미지 예: http://example.com/images/suzy2.png

감사합니다 ^^

2041908837_1667240571.3061.png

 

* view.skin.php


<!-- Image Comparison -->
  
<style>
  *{box-sizing: border-box;}
  .img-comp-container{
    position: relative;
    height:540px;
  }
  .img-comp-img{
    position: absolute;
    width:auto;
    height:auto;
    overflow:hidden;
  }
  .img-comp-img img{
    display:block;
    vertical-align: middle;
  }
  .img-comp-slider{
    position: absolute;
    z-index: 9;
    cursor: ew-resize;
/*   set the appearance of the slider */
    width:40px; height: 40px; background-color:#2196f3; opacity: 0.7;border-radius: 50%;
  }
</style>
  
<script>
function initComparisons() {
  var x, i;
  /*find all elements with an "overlay" class:*/
  x = document.getElementsByClassName("img-comp-overlay");
  for (i = 0; i < x.length; i++) {
    /*once for each "overlay" element:
    pass the "overlay" element as a parameter when executing the compareImages function:*/
    compareImages(x[i]);
  }
  function compareImages(img) {
    var slider, img, clicked = 0, w, h;
    /*get the width and height of the img element*/
    w = img.offsetWidth;
    h = img.offsetHeight;
    
    /*set the width of the img element to 50%:*/
    img.style.width = (w / '<?php echo $view['wr_1']; // 슬라이드버튼위치  ?>') + "px";
    /*create slider:*/
    slider = document.createElement("DIV");
    slider.setAttribute("class", "img-comp-slider");
    /*insert slider*/
    img.parentElement.insertBefore(slider, img);
    
    /*position the slider in the middle:*/
    slider.style.top = (h / 2) - (slider.offsetHeight / 2) + "px";
    slider.style.left = (w / '<?php echo $view['wr_1']; // first large image ?>') - (slider.offsetWidth / 2) + "px";
    /*execute a function when the mouse button is pressed:*/
    slider.addEventListener("mousedown", slideReady);
    /*and another function when the mouse button is released:*/
    window.addEventListener("mouseup", slideFinish);
    /*or touched (for touch screens:*/
    slider.addEventListener("touchstart", slideReady);
    /*and released (for touch screens:*/
    window.addEventListener("touchend", slideFinish);
    function slideReady(e) {
      /*prevent any other actions that may occur when moving over the image:*/
      e.preventDefault();
      /*the slider is now clicked and ready to move:*/
      clicked = 1;
      /*execute a function when the slider is moved:*/
      window.addEventListener("mousemove", slideMove);
      window.addEventListener("touchmove", slideMove);
    }
    function slideFinish() {
      /*the slider is no longer clicked:*/
      clicked = 0;
    }
    function slideMove(e) {
      var pos;
      /*if the slider is no longer clicked, exit this function:*/
      if (clicked == 0) return false;
      /*get the cursor's x position:*/
      pos = getCursorPos(e)
      /*prevent the slider from being positioned outside the image:*/
      if (pos < 0) pos = 0;
      if (pos > w) pos = w;
      /*execute a function that will resize the overlay image according to the cursor:*/
      slide(pos);
    }
    function getCursorPos(e) {
      var a, x = 0;
      e = (e.changedTouches) ? e.changedTouches[0] : e;
      /*get the x positions of the image:*/
      a = img.getBoundingClientRect();
      /*calculate the cursor's x coordinate, relative to the image:*/
      x = e.pageX - a.left;
      /*consider any page scrolling:*/
      x = x - window.pageXOffset;
      return x;
    }
    function slide(x) {
      /*resize the image:*/
      img.style.width = x + "px";
      /*position the slider:*/
      slider.style.left = img.offsetWidth - (slider.offsetWidth / 2) + "px";
    }
  }
}
</script>
    
  </head>
  <body>
<div class="img-comp-container">      
      <div class="img-comp-img">
      <img src="<?php echo $view['wr_2']; // first image ?>" alt="" width="960" height="540">
      </div>
      <div class="img-comp-img img-comp-overlay">
        <img src="<?php echo $view['wr_3']; // second image ?>" width="960" height="540" alt="">
      </div>      
    </div>
<script>
/*Execute a function that will execute an image compare function for each element with the img-comp-overlay class:*/
initComparisons();
</script>
          
<!-- Image Comparison -->  

 

 

* write.skin.php


<!-- Image Compare -->
      
<!--  Slide Button Positon -->
<!--  1: 버튼이 오른쪽에 위치, 2: 버튼이 가운데 위치, 2~500사이: 왼쪽에서 가운데 사이에 버튼이 위치.   -->
<input type=text class="frm_input full_input" name="wr_1" value="<?php echo $write['wr_1']; ?>" placeholder="버튼의 위치를 숫자로 입력합니다 wr_1: 1:오른쪽, 2:가운데, 2~500사이:왼쪽에서 가운데 사이 적당히 위치 ">
<!-- first image -->
<input type=text class="frm_input full_input" name="wr_2" value="<?php echo $write['wr_2']; ?>" placeholder="이미지경로 wr_2:예 http://example.com/images/suzy1.png ">  
      
<!-- second image -->
<input type=text class="frm_input full_input" name="wr_3" value="<?php echo $write['wr_3']; ?>" placeholder="이미지경로 wr_3:예 http://example.oom/images/suzy2.png ">      
<!-- Image Compare -->

 

 

 

추천
17

댓글 전체

head.php에 로고부분을 텍스트로 바꾸고 css로 처리한  것입니다.
<div id="logo">부분에서 로고를 <h1>태그로 바꾼 것입니다.

<style>
.glowkim {
  font-size: 25px;
  color: #fff;
  text-align: center;
  animation: glowkim 2s ease-in-out infinite alternate;
}

@-webkit-keyframes glowkim {
  from {
    text-shadow: 0 0 10px #fff, 0 0 20px #fff, 0 0 30px #e60073, 0 0 40px #e60073, 0 0 50px #e60073, 0 0 60px #e60073, 0 0 70px #e60073;
  }
 
  to {
    text-shadow: 0 0 20px #fff, 0 0 30px #ff4da6, 0 0 40px #ff4da6, 0 0 50px #ff4da6, 0 0 60px #ff4da6, 0 0 70px #ff4da6, 0 0 80px #ff4da6;
  }
}
</style>

<div id="hd_wrapper">

<div id="logo">

<a href="<?php echo G5_URL ?>">
 
<h1 id="kims" class="glowkim" style="font-size: 20px; float: left; text-align:right; color: white;  padding-top: 5px;" title="이은경시인 홈페이지">Poetry is Life !!</h1>

</a>

<!--이미지를 주석처리하고 텍스트로 바꾼다. <img src="<?php echo G5_IMG_URL ?>/logo.png" alt="<?php echo $config['cf_title']; ?>">-->
</div>

원소스 출처: https://www.w3schools.com/howto/howto_css_glowing_text.asp

관심을 가져주셔서 감사드립니다^^
w3shools의 js소스를 갤러리에 적용한 것 뿐입니다.
비타주리님의 스킨을 보면 자바스크립트 함수를 직접 만들어 사용하시는데요.
늘 말씀드리지만 비타주리님 스킨을 보고 많이 배웁니다.
따뜻한 관심에 감사드립니다^^
이미지업로드 해서 사용하는 경우는
view.skin.php의 90번째 줄 부근의 파일 출력부분을 주석처리합니다.
        <?php
        // 파일 출력
//        $v_img_count = count($view['file']);
//        if($v_img_count) {
//            echo "<div id=\"bo_v_img\">\n";
//
//            foreach($view['file'] as $view_file) {
//                echo get_file_thumbnail($view_file);
//            }
//
//            echo "</div>\n";
//        }
        ?>

그리고
221번째 줄에서
img src부분을 바꾸어줍니다.

기존 여분필드를 사용하는 코드
<div class="img-comp-container">     
      <div class="img-comp-img">
      <img src="<?php echo $view['wr_2']; // first large image ?>" alt="" width="960" height="540">
      </div>
      <div class="img-comp-img img-comp-overlay">
        <img src="<?php echo $view['wr_3']; // first large image ?>" width="960" height="540" alt="">
      </div>     
    </div>


파일업로드를 사용하는코드
<div class="img-comp-container">     
      <div class="img-comp-img">
      <img src="<?php echo $view['file'][0]['file'] ? $view['file'][0]['path'].'/'.$view['file'][0]['file'] : '' ?>" alt="" width="960" height="540">
      </div>
      <div class="img-comp-img img-comp-overlay">
        <img src="<?php echo $view['file'][1]['file'] ? $view['file'][1]['path'].'/'.$view['file'][1]['file'] : '' ?>" width="960" height="540" alt="">
      </div>     
    </div>
첫째, 둘째 업로드한 파일이 나타납니다.
파일출력부분을 주석처리하지 않으면 업로드한 파일이 2중으로 출력이 됩니다.
전체 2,431 |RSS
그누보드5 스킨 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT