32 lines
987 B
PHP
32 lines
987 B
PHP
<?php
|
|
|
|
class MediaYoutube extends MediaRenderer{
|
|
private $link;
|
|
|
|
public function __construct($model){
|
|
$this->link = $model->link;
|
|
}
|
|
|
|
public function asText(array $opt = array()){
|
|
$size = MediaRendererInterface::SIZE_ORIGINAL;
|
|
if(array_key_exists("size", $opt) && array_key_exists($opt["size"], self::$SIZES)){
|
|
$size = self::$SIZES[$opt["size"]];
|
|
}
|
|
// return $this->link;
|
|
return '<iframe itemprop="video" width='.$size["width"].' height='.$size["height"].' src="'.$this->getVideoLink().'" frameborder="0" allowfullscreen="1"></iframe>';
|
|
// return '<iframe width="560" height="315" src="https://www.youtube.com/embed/4qkv-iy_MaQ" frameborder="0" allowfullscreen></iframe>';
|
|
}
|
|
|
|
public function render(array $opt = array()){
|
|
echo $this->asText($opt);
|
|
}
|
|
|
|
public function getThumbnailLink(){
|
|
return 'https://i.ytimg.com/vi/'.$this->link.'/0.jpg';
|
|
}
|
|
|
|
public function getVideoLink(){
|
|
return 'https://www.youtube.com/embed/'.$this->link.'?autoplay=0';
|
|
}
|
|
}
|
|
?>
|