채택완료

첨부파일 1번이 없을 때 썸네일 이미지 출력 오류

2023-07-14 (금) 16:04:04 2,429

view에선 첨부파일이 2부터 보이도록 설정하였고

list에선 첨부파일 1이 없을 시 no-img로 대체되도록 하였습니다.

분명 첨부파일1을 첨부하였는데도 모든 썸네일 이미지가 no-img로 나오는데

view가 문제인지 list가 문제인지 제대로 돌아가지않는 문제점을 모르겠습니다...

고수분들 어느 부분이 문제점인지 알려주세요 ㅜㅜ

갤러리 게시판 view.skin.php 코드

Copy
<?php

        // 파일 출력

        $v_img_count = count($view['file']);

        if($v_img_count) {

            echo "<div id=\"bo_v_img\">\n";

 

            for ($i=1; $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";

        }

         ?>

갤러리 게시판 list.skin.php 코드

Copy
<?php

                        if ($list[$i]['is_notice']) { // 공지사항  ?>

                                <span class="is_notice" style="<?php echo $line_height_style; ?>">공지</span>

                                <?php } else {

                            $thumb = get_list_thumbnail($board['bo_table'], $list[$i]['wr_id'], $board['bo_gallery_width'], $board['bo_gallery_height'], false, true);

 

                            if($list[$i]['file'][0]['file']) {

                                $img_content = '<img src="'.$thumb['src'].'" alt="'.$thumb['alt'].'" >';

                            } else {

                                $img_content = '<img src="/img/no-img.jpg">';

                            }

 

                            echo run_replace('thumb_image_tag', $img_content, $thumb);

                        }

                         ?>
|

답변 4개 / 댓글 4개

채택된 답변
+20 포인트

list는 view 처럼 첨부파일 가져오는 변수가 기본으로 설정 안되있을겁니다.

Copy
<?php
                        if ($list[$i]['is_notice']) { // 공지사항  ?>
                                <span class="is_notice" style="<?php echo $line_height_style; ?>">공지</span>
                                <?php } else {
             $list_file = get_file($bo_table, $list[$i]['wr_id']);
                            $thumb = get_list_thumbnail($board['bo_table'], $list[$i]['wr_id'], $board['bo_gallery_width'], $board['bo_gallery_height'], false, true);
 
                              if($list_file[0][file]) {
                                $img_content = '<img src="'.$thumb['src'].'" alt="'.$thumb['alt'].'" >';
                            } else {
                                $img_content = '<img src="/img/no-img.jpg">';
                            }
 
                            echo run_replace('thumb_image_tag', $img_content, $thumb);
                        }
                         ?>

이렇게 해보세요

$list_file = get_file($bo_table, $list[$i]['wr_id']);

   if($list_file[0][file]) {

추가입니다.

답변에 대한 댓글 1개

이렇게하니 되었습니다! list가 첨부파일을 가져오는 변수가 기본으로 없다는걸 처음 알았네요! 이렇게 또 배워갑니다 감사합니다!

목록에서 이미지가 안나오는 것은

관리자페이지 -->게시판관리--> 목록에서 화일사용에 체크하세요

답변에 대한 댓글 1개

제 기존 코드에서 목록에서 파일사용을 체크하니 되네요! 게시판 기능을 더 정확히 알아야겠습니다..이렇게 또 유익한 정보를 알아가네요 감사합니다!

Copy
<?php
                        if ($list[$i]['is_notice']) { // 공지사항  ?>
                            <span class="is_notice" style="<?php echo $line_height_style; ?>">공지</span>
                       <?php } else {
                            $thumb = get_list_thumbnail($board['bo_table'], $list[$i]['wr_id'], $board['bo_gallery_width'], $board['bo_gallery_height'], false, true);
                            if($thumb['src']&&$list[$i]['file'][0]['file']) {
                                $img_content = '<img src="'.$thumb['src'].'" alt="'.$thumb['alt'].'" >';
                            } else {
                                $img_content = '<img src="../images/common/no-img.jpg">';
                            }
                            echo $img_content;
                        }
                         ?>

답변에 대한 댓글 1개

이렇게도 해봤는데 똑같습니다 ㅜㅜ
2023-07-14 (금) 16:09:33

게시판 설정에서 파일을 가지고 오게 하셨나요? 가지고 오게하셨으면 해당 변수에 제대로 값이 들어가 있나 체크를 해보셔야 할거 같습니다.

답변에 대한 댓글 1개

for ($i=1; $i<=count($view['file']); $i++) { 에서 i=0을 하면 첨부파일1도 페이지 내에 나오는거보면 변수는 맞는것같습니다..

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