유튜브/비메오 ID로부터 비디오 썸네일 갖고오기 (youtube.lib.php)
[code]
<?php
if (!defined('_GNUBOARD_')) exit;
function get_youtube_id($contents)
{
if(!$contents)
return false;
preg_match('/(?:youtube(?:-nocookie)?\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|shorts\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/', $contents, $match); //all working included shorts and iframe
return $match[1] ?? false;
}
function get_youtube_thumbnail($youtube_id, $thumb_str="0"){
if(!$youtube_id)
return false;
return "https://img.youtube.com/vi/".$youtube_id."/".$thumb_str.".jpg";
}
function get_vimeo_id($contents)
{
if(!$contents)
return false;
$pattern = '/(?:https?:\/\/)?(?:www\.)?(?:player\.)?vimeo\.com\/(?:video\/|channels\/(?:\w+\/)?|groups\/(?:[^\/]*)\/videos\/|album\/(?:\d+)\/video\/|)(\d+)(?:[a-zA-Z0-9_-]+)?/i';
preg_match($pattern, $contents, $match);
return $match[1] ?? false;
function get_vimeo_thumbnail($id) {
if (!$id) return false;
$url = "https://vimeo.com/api/oembed.json?url=https://vimeo.com/" . $id;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);
curl_close($ch);
if ($response) {
$data = json_decode($response);
return $data->thumbnail_url ?? false;
}
return false;
}
[/code]
게시판 목록
그누보드5 팁자료실
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 공지 | 3년 전 | 4402 | ||
| 2514 | 1년 전 | 902 | ||
| 2513 |
베리소프트
|
1년 전 | 619 | |
| 2512 |
|
1년 전 | 949 | |
| 2511 |
|
1년 전 | 1078 | |
| 2510 | 1년 전 | 1006 | ||
| 2509 | 1년 전 | 1057 | ||
| 2508 | 1년 전 | 1307 | ||
| 2507 | 1년 전 | 686 | ||
| 2506 | 1년 전 | 1253 | ||
| 2505 |
|
1년 전 | 1207 | |
| 2504 | 1년 전 | 1407 | ||
| 2503 | 1년 전 | 944 | ||
| 2502 | 1년 전 | 1070 | ||
| 2501 | 1년 전 | 1169 | ||
| 2500 |
welcome
|
1년 전 | 1077 | |
| 2499 |
하늘그루터기
|
1년 전 | 870 | |
| 2498 | 1년 전 | 1177 | ||
| 2497 | 1년 전 | 644 | ||
| 2496 | 1년 전 | 963 | ||
| 2495 |
|
1년 전 | 1417 | |
| 2494 | 1년 전 | 944 | ||
| 2493 | 1년 전 | 945 | ||
| 2492 | 1년 전 | 1155 | ||
| 2491 | 1년 전 | 1120 | ||
| 2490 | 1년 전 | 1089 | ||
| 2489 | 1년 전 | 1019 | ||
| 2488 | 1년 전 | 772 | ||
| 2487 |
|
1년 전 | 1209 | |
| 2486 | 1년 전 | 830 | ||
| 2485 | 1년 전 | 1006 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기