COMING SOON 🚀

유튜브 득템 눈알이 반짝!!!!!

· 1년 전 · 853

 

http://wittazzurri.phps.kr/main/js_hook/2

 

오늘 지한님 라이믹스 소식 - https://sir.kr/cm_free/1705422

에서 유튜브 정보 하나를 득템했네요. 윤삼님 감사요 - https://rhymix.org/free/1852364

 

제가 미디어라면 환장하는 수준이라 바로 이미지에서 자동으로 일반비율과 쇼츠비율을 분기하는 코드를 빼서 게시글로 올려 보았습니다.

 

----------

 

<img src="https://i.ytimg.com/vi/HwAjty0pdZk/frame0.jpg">
<img src="https://i.ytimg.com/vi/okGctSoD0VU/frame0.jpg">

 

----------

 

위와 같이 이미지태그를 게시글에 적어주구요.

view.skin.php 하단에는 아래처럼 해 주었습니다. 이미지개수는 몇개라도 상관이 없습니다.

일반비율과 쇼츠비율을 이미지에서 판별하여 아이프레임 태그로 문자열을 치환합니다.

 

----------

 

<style>
iframe[src*='www.youtube.com/'] { display:block; border:none; margin:0 auto; }
</style>
<script>
for (yt of document.querySelectorAll("img[src*='i.ytimg.com/']")) {
    yt.onload = function() {
        this.widthPercent = "width:" + (this.offsetWidth > this.offsetHeight ? 100 : 70) + "%;";
        this.widthPixel = "max-width:" + (this.offsetWidth > this.offsetHeight ? 960 : 540) + "px;";
        this.whRatio = "aspect-ratio:" + (this.offsetWidth > this.offsetHeight ? "16/9" : "9/16");
        this.outerHTML ="<iframe style='" + this.widthPercent + this.widthPixel + this.whRatio + "' src='https://www.youtube.com/embed/" + this.src.split("/vi/")[1].slice(0, 11) + "' allowfullscreen></iframe>";
    }
}
</script>

 

----------

----------

 

바로 확인하고 싶다면

 

https://wittazzurri.com/editor/html_editor.php 를 열어서 아래 코드를 넣고 확인해 보세요.

 

<img src="https://i.ytimg.com/vi/HwAjty0pdZk/frame0.jpg">
<br>
<img src="https://i.ytimg.com/vi/okGctSoD0VU/frame0.jpg">

<style>
iframe[src*='www.youtube.com/'] { display:block; border:none; margin:0 auto; }
</style>
<script>
for (yt of document.querySelectorAll("img[src*='i.ytimg.com/']")) {
    yt.onload = function() {
        this.widthPercent = "width:" + (this.offsetWidth > this.offsetHeight ? 100 : 70) + "%;";
        this.widthPixel = "max-width:" + (this.offsetWidth > this.offsetHeight ? 960 : 540) + "px;";
        this.whRatio = "aspect-ratio:" + (this.offsetWidth > this.offsetHeight ? "16/9" : "9/16");
        this.outerHTML ="<iframe style='" + this.widthPercent + this.widthPixel + this.whRatio + "' src='https://www.youtube.com/embed/" + this.src.split("/vi/")[1].slice(0, 11) + "' allowfullscreen></iframe>";
    }
}
</script>

|
댓글을 작성하시려면 로그인이 필요합니다.

자유게시판

+
제목 글쓴이 날짜 조회
1년 전 조회 786
1년 전 조회 928
1년 전 조회 767
1년 전 조회 913
1년 전 조회 774
1년 전 조회 799
1년 전 조회 775
1년 전 조회 868
1년 전 조회 1,038
1년 전 조회 758
1년 전 조회 1,006
1년 전 조회 838
1년 전 조회 786
1년 전 조회 814
1년 전 조회 854
1년 전 조회 839
1년 전 조회 974
1년 전 조회 935
1년 전 조회 1,019
1년 전 조회 1,048
1년 전 조회 901
1년 전 조회 954
1년 전 조회 1,058
1년 전 조회 865
1년 전 조회 1,018
1년 전 조회 972
1년 전 조회 925
1년 전 조회 925
1년 전 조회 859
1년 전 조회 1,071