유튜브 썸네일이 보이지 않네요...(data/file에 저장이 안됩니다) 도움좀 주세요...

유튜브 썸네일이 보이지 않네요...(data/file에 저장이 안됩니다) 도움좀 주세요...

QA

유튜브 썸네일이 보이지 않네요...(data/file에 저장이 안됩니다) 도움좀 주세요...

본문


<?
$bo_gallery_cols = "2";
$td_width = (int)(100 /$bo_gallery_cols);
$thumb_width = $webzine_youtube_type_img_width ; //썸네일 가로길이
$thumb_height = $webzine_youtube_type_img_height; //썸네일 세로길이
// 썸네일 디렉토리
$thumb_path = G5_DATA_PATH.'/file/'.$bo_table; 
$thumb_file_path = G5_DATA_URL.'/file/'.$bo_table; 
?>
<table width="<?=$width?>" border="0" cellspacing="0" cellpadding="0" align="center">
<tr><td height="1" bgcolor="#CCCCCC"></td><tr>
</table>
<table width="<?=$width?>" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<!-- 목록 -->
  <?php 
    for ($i=0; $i<count($list); $i++) {
    $file = get_file($bo_table, $list[$i]['wr_id']); 

            if($i>0 && ($i % $bo_gallery_cols == 0))
                echo "</tr><tr>";
           $bg = 'bg'.($i%2);
    ?>
  <?php if ($list[$i][wr_link1]) { //동영상 플레이어 
      
       // 실제 구동 동영상 = 링크가 있으면 먼저 출력함
        if ($list[$i][wr_link1]) { $mov_play_file = "{$list[$i][wr_link1]}"; } 
       
   
               $img = "";
            
        // 썸네일 생성                
        if ($list[$i][wr_link1]) {            
                 $youtube = str_replace("https://youtu.be/","","{$list[$i][wr_link1]}");
                 $youtueb_img = "http://img.youtube.com/vi/{$youtube}/0.jpg";
                 
                if ($youtueb_img) { 
              // 유튜브 이미지 파일에서 썸네일 추출
                 $mov_file_path = "{$youtueb_img}";
                 $mov_file_thumb = "{$youtueb_img}"; 
                 $thumb = "{$thumb_path}/thumb-youtube_{$list[$i][wr_id]}_{$thumb_width}.jpg";    
                 $img = "{$thumb_file_path}/thumb-youtube_{$list[$i][wr_id]}_{$thumb_width}.jpg";    
                 $thumb_file = $mov_file_thumb;
                }        
               // 썸네일이 없다면
               if (!file_exists($thumb)) {
                createThumb_webzine($thumb_width, $thumb_height, $thumb_file, $thumb, true); //상단을 20px 잘라고 출력함
                }
         }  
            if ($img) {
                 $img_content = '<img src="'.$img.'" width="'.$thumb_width.'" height="'.$thumb_height.'">';
                 } else {
                 $img_content = '<span style="display:inline-block; text-align: center; background-color: #EDEDED; line-height:'.$thumb_height.'px; width:'.$thumb_width.'px;height:'.$thumb_height.'px;">
                 <div style="height:10px;"></div><div class="fa fa-image fa-3x" style="color:#AAAAAA;"></div></span>';
                 }
} 
?>

이 질문에 댓글 쓰기 :

답변 2


if ($list[$i][wr_link1]) {                             
  $youtube = str_replace("https://youtu.be/","","{$list[$i][wr_link1]}");                  .
  $youtueb_img = "http://img.youtube.com/vi/{$youtube}/0.jpg";

 

* 다음줄에 $youtueb_img 를 출력하여 나오는 주소(http://img.youtube.com/vi/~/0.jpg ) 를

브라우저에 직접 입력해서, 이미지 확인이 되는지 살펴보셨으면 합니다.

 

* 지금의 코드는 유튜브 영상의 주소를  'https://youtu.be/~' 로 입력하는 경우에만 문제가 없고,

다른 형태의 주소인 경우는( https://www.youtube.com/watch?v=~ 등) 썸네일 추출을 하지 못할 가능성이 있는 코드입니다.

 

이 부분들을 검토해 볼 수 있을 듯 합니다.

 

$youtueb_img 변수명에 오타가 있는 듯 한데.. $youtube_img 로 모두 고쳐주는 것도 좋을 것 같습니다.

답변 감사합니다 현재 (http://img.youtube.com/vi/~/0.jpg) 을 브라우저에 입력했더니 이미지가 나오는 것은 확인하였습니다. 

 

유튜브 동영상을  'https://youtu.be/~' 업로드 해도 썸네일이 안나오고   ( https://www.youtube.com/watch?v=~ 등) 이런 방식으로 업로드해도 안나오네요....

이후의 코드에서, 어느부분에서 문제가 생기는지..

$thumb_file, $img 를 echo 로 확인해보면서 문제를 살펴볼 수 있습니다.

자체 썸네일 만드는 부분의 오류 확인 및 해결이 어려운 경우에는,

유튜브 자체 썸네일 주소정보를 바로 <img> 태그로 넣어주는 방법을 검토해볼 수 있습니다.

<img src="http://img.youtube.com/vi/~/mqdefault.jpg">

답변을 작성하시기 전에 로그인 해주세요.
전체 0 | RSS
QA 내용 검색
  • 개별 목록 구성 제목 답변작성자조회작성일
  • 질문이 없습니다.

회원로그인

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