Your IP : 216.73.216.240


Current Path : /home/juvelize/saulnois/tmp/install_695d2cf0b4957/src/View/Others/
Upload File :
Current File : /home/juvelize/saulnois/tmp/install_695d2cf0b4957/src/View/Others/Youtube.php

<?php
/*
* @package		Tech Fry Library
* @license		https://www.gnu.org/licenses/gpl-3.0.en.html
*/

namespace TechFry\Library\View\Others;

defined('_JEXEC') or die;

use TechFry\Library\View\Sky\Bootstrap;

class Youtube extends Bootstrap
{
    public function display()
    {
        // config - size, width, height

        $video_id = $this->data;
        
        if (empty($video_id))
        {
            return;
        }
        
        $width_height_atts = ($this->config['size'] == 'fixed') ? 'width="' . $this->config['width'] . '" height="' . $this->config['height'] . '"' : '';
        
        $query = $video_id . '?' . http_build_query($this->config);
        $autoplay_att = $this->config['autoplay'] ? ' allow="autoplay; encrypted-media"' : '';
        
        $output = '<iframe ' . $width_height_atts . ' src="https://www.youtube.com/embed/' . $query .'" frameborder="0"' . $autoplay_att . ' allowfullscreen></iframe>';
        
        if ($this->config['size'] == 'responsive')
        {
            $output = '<div class="embed-responsive">' . $output . '</div>';
        }
        
        return $output;
    }
    
    // Depreciated
    public static function get_output($video_id, $config = array())
    {
        // config - size, width, height
        
        if ($video_id == '')
        {
            return;
        }
        
        $width_height_atts = ($config['size'] == 'fixed') ? 'width="' . $config['width'] . '" height="' . $config['height'] . '"' : '';
        
        $query = $video_id . '?' . http_build_query($config);
        $autoplay_att = $config['autoplay'] ? ' allow="autoplay; encrypted-media"' : '';
        
        $output = '<iframe ' . $width_height_atts . ' src="https://www.youtube.com/embed/' . $query .'" frameborder="0"' . $autoplay_att . ' allowfullscreen></iframe>';
        
        if ($config['size'] == 'responsive')
        {
            $output = '<div class="embed-responsive">' . $output . '</div>';
        }
        
        return $output;
    }
}