Package for generate IFrame with youtube-link
Package for generate IFrame with youtube-link, (*2)
composer require "fomvasss/youtube"
For Laravel < 5.5 register the service provider and aliases in config/app.php:, (*3)
Fomvasss\Youtube\YoutubeServiceProvider::class,
Publish config:, (*4)
php artisan vendor:publish --provider="Fomvasss\Youtube\YoutubeServiceProvider" --tag="config"
Edit file config/youtube.php
, set:
- 'rel' => 0, #show like videos after finish
- 'autoplay' => 0, #autoplay video after open page
- 'loop' => 0, #if 1 - repeat video
- 'controls' => 1, #show control button in player
- 'showinfo' => 1, #show info about video (title, time)
- 'width' => 640, #width video
- 'height' => 360, #height video
- 'frameborder' => 0, #border on player, (*5)
Youtube
use Fomvasss\Youtube\Facades\Youtube;
Now example, you can use next:, (*6)
Youtube::iFrame('https://www.youtube.com/watch?v=Dxk47dya8_k'); //returt String iframe
You get next iframe:, (*7)
<iframe width="640" height="360" src="http://www.youtube.com/embed/Dxk47dya8_k?rel=0&autoplay=0&controls=1&showinfo=1" frameborder="0"></iframe>
You can set more parameters in array:, (*8)
$link = 'https://www.youtube.com/watch?v=Dxk47dya8_k'; Youtube::iFrame($link, ['rel'=> 0, 'autoplay'=>1, 'controls'=>1, 'showinfo'=>1, 'width'=>720, 'height'=>460, 'frameborder'=>0])
If are you not set some parameters, it well have default values (with config youtube.php):, (*9)
@youtube()
@youtube("https://www.youtube.com/watch?v=Dxk47dya8_k") @youtube('<iframe width="640" height="360" src="https://www.youtube.com/embed/Dxk47dya8_k?rel=0&controls=0&showinfo=0" frameborder="0" allowfullscreen></iframe>') @youtube("Dxk47dya8_k")
Also you can set more parameters in array:, (*10)
@youtube('https://www.youtube.com/watch?v=Dxk47dya8_k', ['width'=>720, 'height'=>460,])
If in config/youtube.php sett 'bootstrap-responsive-embed' => true,
or array parameters is set 'bootstrap-responsive-embed' => true
then we give next:, (*11)
<div class="embed-responsive embed-responsive-16by9"> <iframe class="embed-responsive-item" src="..."></iframe> </div>
Then the parameters height
& weight
are not using (ignoring)
You also can use bootstrap-ratio
parameters. Available next value ratio: 1by1 | 4by3 | 16by9 | 21by9, (*12)
youtube_iframe()
youtube_iframe('https://www.youtube.com/watch?v=Dxk47dya8_k');