[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]
게시글 목록
| 번호 | 제목 |
|---|---|
| 23254 | |
| 23244 | |
| 23241 | |
| 23236 | |
| 23200 | |
| 23199 | |
| 23179 | |
| 23174 | |
| 23138 | |
| 23128 | |
| 23125 | |
| 23116 | |
| 23109 | |
| 23099 | |
| 23092 | |
| 23083 | |
| 23079 | |
| 23063 | |
| 23050 | |
| 23036 | |
| 23029 | |
| 23007 | |
| 23003 | |
| 22983 | |
| 22959 | |
| 22943 | |
| 22939 | |
| 22934 | |
| 22905 | |
| 22897 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기