fomvasss / youtube
Package for generate IFrame with youtube-link
Installs: 3 197
Dependents: 0
Suggesters: 0
Security: 0
Stars: 8
Watchers: 2
Forks: 3
Open Issues: 2
Type:package
Requires
- php: >=5.6.0
README
Package for generate IFrame with youtube-link
Install
composer require "fomvasss/youtube"
For Laravel < 5.5 register the service provider and aliases in config/app.php:
Fomvasss\Youtube\YoutubeServiceProvider::class,
Publish config:
php artisan vendor:publish --provider="Fomvasss\Youtube\YoutubeServiceProvider" --tag="config"
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
-
'bootstrap-responsive-embed' => false, #add bootstrap container with class "embed-responsive"
-
'bootstrap-ratio' => '16by9', #set default ratio 1by1 | 4by3 | 16by9 | 21by9
Using
Using facades Youtube
use Fomvasss\Youtube\Facades\Youtube;
Now example, you can use next:
Youtube::iFrame('https://www.youtube.com/watch?v=Dxk47dya8_k'); //returt String iframe
You get next iframe:
<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:
$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):
Using blade directive in template@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:
@youtube('https://www.youtube.com/watch?v=Dxk47dya8_k', ['width'=>720, 'height'=>460,])
Using Bootstrap responsive container
If in config/youtube.php sett 'bootstrap-responsive-embed' => true,
or array parameters is set 'bootstrap-responsive-embed' => true
then we give next:
<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
Using helper-function youtube_iframe()
youtube_iframe('https://www.youtube.com/watch?v=Dxk47dya8_k');