fernandovaller / thumbnail
从URL获取youtube和vimeo视频的缩略图。返回的信息是缩略图的ID和URL。
v1.0.5
2021-12-28 14:10 UTC
Requires
- guzzlehttp/guzzle: 7.*
README
从URL获取youtube和vimeo视频的缩略图。返回的信息是缩略图的ID和URL。
安装
使用以下命令安装最新版本:
$ composer require fernandovaller/thumbnail
基本用法
<?php use FVCode\Thumbnail\Thumbnail; require __DIR__ . '/vendor/autoload.php'; $th = new Thumbnail(); $url = 'youtube|vimeo URL video'; // The returned information is ID and URL of the thumbnail $data = $th->get($url);
配置
如果Vimeo视频有原点限制,在这种情况下,请将设置添加到请求中模拟原点。
<?php use FVCode\Thumbnail\Thumbnail; require __DIR__ . '/vendor/autoload.php'; $config = [ 'origin' => 'https://www.google.com' ]; $th = new Thumbnail($config); $url = 'youtube|vimeo URL video'; // The returned information is ID and URL of the thumbnail $data = $th->get($url);
Noembed
<?php use FVCode\Thumbnail\Thumbnail; require __DIR__ . '/vendor/autoload.php'; $th = new Thumbnail(); $url = 'youtube|vimeo URL video'; // The returned information is array [title, thumbnail_url, video_id, ...] $data = $th->getNoembed($url);