Skip to content

abdussalam-alali/Laravel-Youtube-iframe-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Samo/YoutubeIframe

get youtube players iframes from URL or Video ID easily

install

composer require samo/youtubeiframe

Usage

In controller

use Samo\YoutubeIframe\Iframe;
public function index() 
{
    $iframe = Iframe::css('border-radius:50px;')
            ->width(100,'%')
            ->height(400,'px')
            ->noFullScreen()
            ->get('https://www.youtube.com/watch?v=35JzR2ymxJE');
    return $iframe;
}

Result:

image of mr bing

In view

<div class="video_container">
{!! Samo\YoutubeIframe\Iframe::css('border-radius:50px;')
            ->width(100,'%')
            ->height(400,'px')
            ->noFullScreen()
            ->get('https://www.youtube.com/watch?v=35JzR2ymxJE')!!}
</div>

Available methods:

css($str)

Defines additional CSS properities sperated by ';'
Example :
Iframe::css('border:1px solid #000;opacity:0.7')->get('35JzR2ymxJE');

height($val=300,$unit='px')

Sets the player height (Default is 300px)
Example :
Iframe::height(500,'px')->get('35JzR2ymxJE');

width($val=500,$unit='px')

Sets the player width (default is 500px)
Example :
Iframe::width(500,'px')->get('35JzR2ymxJE');

get($urlOrID)

Returns the Iframe markup you can pass URL or Video ID
Accepted url format :
youtube.com/watch?v=xxxxxx
youtu.be.com/xxxxxxx
youtube.com/?v=xxxxxx

noFullScreen()

disable full screen feature

addAttribute($att)

adds a HTML attributes
Example :
Iframe::addAttribute('class="pt-5"')->addAttribute('id="pl1")->get('35JzR2ymxJE');

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages