사이트 내 전체검색
PHP
유튜브에서 이미지 검은 배경 섬네일 짜르기
프리이미지
https://cmd.kr/php/893 URL이 복사되었습니다.

본문

참고소스:

https://stackoverflow.com/questions/33604360/using-css-only-to-remove-the-black-bars-from-youtube-hqdefault-image

 

<div class="stretchy-wrapper">

    <div>
        <img src="http://img.youtube.com/vi/dA6Jsr7MWw4/hqdefault.jpg" style="overflow: hidden; width:100%;"/>
    </div>

</div> 

 

body {

    width: 70%;
    margin: 8px auto;
}

div.stretchy-wrapper{
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 */
    position: relative;
    background: blue;
    overflow: hidden;
}

div.stretchy-wrapper > div {
    position: absolute;
    top: -16.75%; bottom: 0; left: 0; right: 0; 

} 

 

 

결과물 :

 

$img='';

if($thumb['src']) $img= $thumb['src'];

if (strstr($img,'youtube.com')) {

$img_content = "

<div class=\"stretchy-wrapper\">

<div>

<img src=\"$img\" style=\"overflow: hidden; width:100%;\"/>

</div>

</div>";

} else if($img) {

$img_content = '<img src="'.$img.'" alt="'.htmlspecialchars($list[$i][wr_subject]).'">';

} else {

$img_content = '<span class="noimage">no image</span>';

}

echo $img_content;

 

작성 : 김성대

 

댓글목록

등록된 댓글이 없습니다.

PHP
871 (1/18P)

Search

Copyright © Cmd 명령어 18.226.98.166