samo / youtubeiframe
get a youtube video embedded iframe easly from url or video id
This package is auto-updated.
Last update: 2025-04-14 21:43:38 UTC
README
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:
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');