Пример #1
0
    public static function embedVideo($url, $params = array())
    {
        $data = Tools::parseMediaUrl($url);
        $class = isset($params['class']) ? $params['class'] : "";
        $width = isset($params['width']) ? 'width="' . $params['width'] . '"' : "";
        $height = isset($params['height']) ? 'height="' . $params['height'] . '"' : "";
        $embedCode = "";
        if ($data) {
            if ($data['sourceKey'] == 'youtube') {
                $embedCode = '
					<div class="videoContainer ' . $class . '">
						<iframe ' . $width . ' ' . $height . ' src="//www.youtube.com/embed/' . $data['originalId'] . '" frameborder="0" allowfullscreen></iframe>
					</div>
				';
            } else {
                $embedCode = '
					<div class="videoContainer ' . $class . '">
						<iframe src="//player.vimeo.com/video/' . $data['originalId'] . '"
							' . $width . '
							' . $height . '
							frameborder="0"
							webkitallowfullscreen
							mozallowfullscreen allowfullscreen>
						</iframe>
					</div>
				';
            }
        }
        return $embedCode;
    }