drolean / laravel-video-embed
用于 dereuromark/MediaEmbed 的 Laravel 扩展包,包含缩略图功能
1.0
2018-11-12 12:42 UTC
Requires
- dereuromark/media-embed: ^0.4
This package is not auto-updated.
Last update: 2024-09-25 14:17:20 UTC
README
对 dereuromark/MediaEmbed 的简单包装,用于生成流行媒体托管服务的嵌入 HTML,并基于 Joe1992w/laravel-media-embed 添加缩略图功能。
安装
composer require merujan99/laravel-video-embed:dev-master
或者
"require": { "merujan99/laravel-video-embed": "dev-master", },
composer install
服务提供者
'providers' => [ // Others... Merujan99\LaravelVideoEmbed\Providers\LaravelVideoEmbedServiceProvider::class, ],
外观
'aliases' => [ // Others... 'LaravelVideoEmbed' => Merujan99\LaravelVideoEmbed\Facades\LaravelVideoEmbed::class, ],
用法
//URL to be used for embed generation $url = "https://www.youtube.com/watch?v=8eK-5ivYb3o"; //Optional array of website names, if present any websites not in the array will result in false being returned by the parser $whitelist = ['YouTube', 'Vimeo']; //Optional parameters to be appended to embed $params = [ 'autoplay' => 1, 'loop' => 1 ]; //Optional attributes for embed container $attributes = [ 'type' => null, 'class' => 'iframe-class', 'data-html5-parameter' => true ]; return LaravelVideoEmbed::parse($url, $whitelist); // "<iframe src="https://www.youtube.com/embed/8eK-5ivYb3o?wmode=transparent" type="text/html" width="480" height="295" frameborder="0" allowfullscreen></iframe>" return LaravelVideoEmbed::parse($url); // "<iframe src="https://www.youtube.com/embed/8eK-5ivYb3o?wmode=transparent" type="text/html" width="480" height="295" frameborder="0" allowfullscreen></iframe>" return LaravelVideoEmbed::parse($url, ['Vimeo']); // false return LaravelVideoEmbed::parse($url, $whitelist, $params, $attributes) //<iframe src="https://www.youtube.com/embed/8eK-5ivYb3o?wmode=transparent&autoplay=1&loop=1" type="" width="480" height="295" frameborder="0" allowfullscreen class="iframe-class" data-html5-parameter></iframe> return LaravelVideoEmbed::getYoutubeThumbnail($url) //https://<youtube image thumbnail with max resolution>. usage: <img src="{{ LaravelVideoEmbed::getYoutubeThumbnail($url) }}">