아래 코드를 이용하여 리스트 페이지에서 게시글마다 첨부된 이미지를 모두 보여주려고 하고 있습니다..
그런데 클릭하면 원본이미지를 볼수 있고 리스트페이지에서 표시될때는 썸네일로 하고 싶습니다..
현재는 리스트페이지에 원본을 축소한 이미지로 나열되고 있습니다
<?php for ($i=0; $i<count($list); $i++) {?>
<?php for($j = 0; $j <= count($list[$i]['file'])-2; $j++) {
?>
<div class="" style="border: 10px solid hsla(0, 0%, 100%, 0.2);">
<a data-fancybox="gallery" data-caption="<?=$list[$i]['subject']?>" href="<?=$list[$i]['file'][$j]["path"]."/".$list[$i]['file'][$j]["file"];?>">
<img src="<?=$list[$i]['file'][$j]["path"]."/".$list[$i]['file'][$j]["file"];?>" class="lazyload" aria-label="Read more" style="width: 100%; height: 100%; object-fit:cover;">
</a>
</div>
<?php } ?>
<?php } ?>
위에서
<img src="<?=$list[$i]['file'][$j]["path"]."/".$list[$i]['file'][$j]["file"];?>" class="lazyload" aria-label="Read more" style="width: 100%; height: 100%; object-fit:cover;">
부분을 썸네일로 하는 것을 도움바랍니다
답변 6개 / 댓글 4개
<img src="<?php echo thumbnail($list[$i]['file'][$j]['file'], $list[$i]['file'][$j]['file']['path'], $list[$i]['file'][$j]['file']['path'], $board['bo_gallery_width'], $board['bo_gallery_height']);?>">
$board['bo_gallery_width']는 게시판 관리에서 설정한 썸네알 크기
균이님~~ 윈도우11에 php8.3.8 이구요~~ 오류메세지는 첨부이미지와 같습니다
상단메뉴에 드롭다운과 로그인부분에 오류가 생기는데 그부분을 출력되지 않도록하면 오류는 없지만 역시 이미지 출력은 되지 않네요


균이님~` include_once(G5_LIB_PATH.'/thumbnail.lib.php'); 는 상단에 원래 있었구요~ echo 있는 걸루 해봐두 같은 오류이고 화면이 뜨질 않네요~~늦은시간 죄송합니다
답변에 대한 댓글 1개
균이님 답변 감사합니다 그런데
위의 질문부분에서 <img src=~~> 을
<img src="<?php thumbnail($list[$i]['file'][$j]['file'], $list[$i]['file'][$j]['file']['path'], $list[$i]['file'][$j]['file']['path'], $board['bo_gallery_width'], $board['bo_gallery_height']);?>"> 로 교체 했더니 페이지 오류가 뜨네요 ~`게시판 리스트가 출력되지 않고요~~
![]()
답변에 대한 댓글 1개
상단 php부분에 추가하세요
답변 코드에 echo가 빠져서 추가 헸습니다
include_once(G5_LIB_PATH.'/thumbnail.lib.php');
썸네일 디렉토리를 생성해 주시고 다시한번 아래 코드를 참고해보시겠어요?
<?php
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가
include_once(G5_LIB_PATH.'/thumbnail.lib.php');
// 썸네일 생성 함수 호출
function get_thumbnail($file, $width, $height, $quality = 90) {
if ($file) {
$thumb = thumbnail($file, G5_DATA_PATH.'/thumb', $width, $height, true, true);
if (is_array($thumb)) {
return G5_DATA_URL.'/thumb/'.$thumb['source'];
} else {
return $file;
}
}
return '';
}
?>
<?php for ($i=0; $i<count($list); $i++) {?>
<?php for($j = 0; $j <= count($list[$i]['file'])-2; $j++) {
$original_image = $list[$i]['file'][$j]["path"]."/".$list[$i]['file'][$j]["file"];
$thumbnail_image = get_thumbnail($original_image, 150, 150); // 썸네일 크기를 원하는대로 조절하세요
?>
<div class="" style="border: 10px solid hsla(0, 0%, 100%, 0.2);">
<a data-fancybox="gallery" data-caption="<?=$list[$i]['subject']?>" href="<?=$original_image;?>">
<img src="<?=$thumbnail_image;?>" class="lazyload" aria-label="Read more" style="width: 100%; height: 100%; object-fit:cover;">
</a>
</div>
<?php } ?>
<?php } ?>
답변에 대한 댓글 1개
리스트에 출력도 원본이미지 구요~`
윈도우11에 아파치 설치해서 테스트 중인데요~` g5/data/thumb 에는 썸네일이 없구요
g5/data/file/게시판테이블 에 썸네일이 생겼는데 원본은 클릭해도 열리지 않구 썸네일이 있는데 썸네일이 게시판에서 설정한 크기가 아닌 400*300 으로 만들어져 있네요~`
게시판 리스트에서는 원본이 사이즈만 축소되서 나열되구요~`썸네일은 view 페이지 열때 생긴듯합니다
아래의 코드를 한번 참고를 해보세요..
<?php
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가
include_once(G5_LIB_PATH.'/thumbnail.lib.php');
// 썸네일 생성 함수 호출
function get_thumbnail($file, $width, $height, $quality = 90) {
if ($file) {
$thumb = thumbnail($file, G5_DATA_PATH.'/thumb', $width, $height, true, true);
if (is_array($thumb)) {
return G5_DATA_URL.'/thumb/'.$thumb['source'];
} else {
return $file;
}
}
return '';
}
?>
<?php for ($i=0; $i<count($list); $i++) {?>
<?php for($j = 0; $j <= count($list[$i]['file'])-2; $j++) {
$original_image = $list[$i]['file'][$j]["path"]."/".$list[$i]['file'][$j]["file"];
$thumbnail_image = get_thumbnail($original_image, 150, 150); // 썸네일 크기를 원하는대로 조절하세요
?>
<div class="" style="border: 10px solid hsla(0, 0%, 100%, 0.2);">
<a data-fancybox="gallery" data-caption="<?=$list[$i]['subject']?>" href="<?=$original_image;?>">
<img src="<?=$thumbnail_image;?>" class="lazyload" aria-label="Read more" style="width: 100%; height: 100%; object-fit:cover;">
</a>
</div>
<?php } ?>
<?php } ?>
답변에 대한 댓글 1개
답변을 작성하려면 로그인이 필요합니다.
생긴 것으로 볼 수 있습니다
오류 코드 자체는 썸네일 관련 오류는 아닙니다
오류난 페이지에서 소스보기 하면 php에러 코드가 있을 것입니다
그것을 확인해봐야 알겠군요