PHP code example of joe1992w / laravel-media-embed
1. Go to this page and download the library: Download joe1992w/laravel-media-embed library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
joe1992w / laravel-media-embed example snippets
'providers' => [
// Others...
Joe1992w\LaravelMediaEmbed\Providers\LaravelMediaEmbedServiceProvider::class,
],
'aliases' => [
// Others...
'LaravelMediaEmbed' => Joe1992w\LaravelMediaEmbed\Facades\LaravelMediaEmbed::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 LaravelMediaEmbed::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 LaravelMediaEmbed::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 LaravelMediaEmbed::parse($url, ['Vimeo']);
// false
return LaravelMediaEmbed::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>