채택완료

파일첨부시 제일 마지막에 첨부한 이미지가 제일 앞으로 가게하는 방법이 있을까요?

2016-07-01 (금) 17:56:42 4,516

파일첨부시 첨부한 순서의 역순으로 나열되게 하는 방법에 대해 도움을 구합니다.

즉, 제일 마지막에 첨부한 이미지가 제일 앞으로 가게하는 방법이 있을까요?

고수님들의 답변 부탁드립니다.^^;; 

|

답변 3개

채택된 답변
+20 포인트

첨부한 이미지를 마지막에 등록한 순서가 제일 올라가가 보이게 하고싶다는거죠?

view.skin.php파일에보시면

Copy
<?php        // 파일 출력        $v_img_count = count($view['file']);        if($v_img_count) {            echo "<div id=\"bo_v_img\">\n";             for ($i=0; $i<=count($view['file']); $i++) {                if ($view['file'][$i]['view']) {                    //echo $view['file'][$i]['view'];                    echo get_view_thumbnail($view['file'][$i]['view']);                }            }             echo "</div>\n";        }         ?>

이부분의 for문의 조건을 변경하시면 되겠습니다.

아래처럼요

Copy
<?php        // 파일 출력        $v_img_count = count($view['file']);        if($v_img_count) {            echo "<div id=\"bo_v_img\">\n";              for ($i=count($view['file']); $i>=0; $i--) {                if ($view['file'][$i]['view']) {                    //echo $view['file'][$i]['view'];                    echo get_view_thumbnail($view['file'][$i]['view']);                }            }             echo "</div>\n";        }         ?>

앗~!!! 친절한 설명 정말 감사드립니다~!!!!

해결되었어요!!

lib/common.lib.php

수정 하세요

// 파일을 보이게 하는 링크 (이미지, 플래쉬, 동영상)
function view_file_link($file, $width, $height, $content='')
{
    global $config, $board;
    global $g5;
    static $ids;

    if (!$file) return;

    $ids++;

    // 파일의 폭이 게시판설정의 이미지폭 보다 크다면 게시판설정 폭으로 맞추고 비율에 따라 높이를 계산
    if ($width > $board['bo_image_width'] && $board['bo_image_width'])
    {
        $rate = $board['bo_image_width'] / $width;
        $width = $board['bo_image_width'];
        $height = (int)($height * $rate);
    }

    // 폭이 있는 경우 폭과 높이의 속성을 주고, 없으면 자동 계산되도록 코드를 만들지 않는다.
    if ($width)
        $attr = ' width="'.$width.'" height="'.$height.'" ';
    else
        $attr = '';

    if (preg_match("/\.({$config['cf_image_extension']})$/i", $file)) {
        $img = '<a href="'.G5_BBS_URL.'/view_image.php?bo_table='.$board['bo_table'].'&amp;fn='.urlencode($file).'" target="_blank" class="view_image">';
        $img .= '<img src="'.G5_DATA_URL.'/file/'.$board['bo_table'].'/'.urlencode($file).'" alt="'.$content.'" '.$attr.'>';
        $img .= '</a>';

        return $img;
    }
} 

답변을 작성하려면 로그인이 필요합니다.