-
Notifications
You must be signed in to change notification settings - Fork 2
/
YoutubeWidget.php
34 lines (29 loc) · 971 Bytes
/
YoutubeWidget.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
namespace app\components;
use yii\base\Widget;
class YoutubeWidget extends Widget
{
public $code; // exemple if your url is https://www.youtube.com/watch?v=wLiBcpMWXRU then your code is wLiBcpMWXRU
public $h; // height default=250px;
public $w ; // width default=300px;
public function init(){
parent::init();
if(is_null( $this->code)|| !is_string($this->code)){
$this->code = "wLiBcpMWXRU";
}
if(is_null( $this->h)|| !is_string($this->h)){
$this->h = "250px";
}
if(is_null( $this->w)|| !is_string($this->w)){
$this->w = "300px";
}
}
public function run(){
return $this->render("youtube",
[
"code"=>$this->code,
"w"=>$this->w,
"h"=>$this->h,
]);
}
}