Вставка видео через ссылку Youtube, mp4, avi, webm, flv и т.д.(Готовое решение)
Поддержка видео для таких сайтов как:
Для: LS 1.0.3
В /engine/modules/text/Text.class.php
Меняем функцию public function VideoParser($sText)
На это:
Конечно же в /config/jevix.php добавляем нехватающие сайты.
Свои параметры сюда:
Готово!
- youtube.com
- vimeo.com
- rutube.ru
- coub.com
- ok.ru
- vk.com
- dailymotion.com
Для: LS 1.0.3
В /engine/modules/text/Text.class.php
Меняем функцию public function VideoParser($sText)
На это:
public function VideoParser($sText) { // Размеры и атрибуты окна вставленного видео. $iWidth = 620; $iHeight = 360; $iAlign = "center"; $sIframeAttr = 'frameborder="0" webkitAllowFullScreen mozallowfullscreen allowfullscreen="allowfullscreen"'; /** * youtube.com fixed */ $sText = preg_replace( '/<video>(?:http(?:s|):|)(?:\/\/|)(?:www\.|m.|)youtu(?:\.|)be(?:-nocookie|)(?:\.com|)\/(?:e(?:mbed|)\/|v\/|watch\?(?:.+&|)v=|)([a-zA-Z0-9_\-]+?)(&.+)?<\/video>/Ui', '<div align="'.$iAlign.'"><iframe width="'.$iWidth.'" height="'.$iHeight.'" '.$sIframeAttr.' src="//www.youtube.com/embed/$1?modestbranding=1&" frameborder="0" allowfullscreen ></iframe></div>', $sText ); /** * vimeo.com fixed */ $sText = preg_replace( '/<video>http(?:s|):\/\/(?:www\.|)vimeo\.com\/(\d+).*<\/video>/i', '<div align="'.$iAlign.'"><iframe src="//player.vimeo.com/video/$1" width="'.$iWidth.'" height="'.$iHeight.'" '.$sIframeAttr.'></iframe></div>', $sText ); /** * rutube.ru fixed */ $sText = preg_replace( '/<video>http(?:s|):\/\/(?:www\.|)rutube\.ru\/tracks\/(\d+)\.html.*<\/video>/Ui', '<div align="'.$iAlign.'"><iframe src="//rutube.ru/play/embed/$1" width="'.$iWidth.'" height="'.$iHeight.'" '.$sIframeAttr.'></iframe></div>', $sText ); $sText = preg_replace( '/<video>http(?:s|):\/\/(?:www\.|)rutube\.ru\/video\/(\w+)\/?<\/video>/Ui', '<div align="'.$iAlign.'"><iframe src="//rutube.ru/play/embed/$1" width="'.$iWidth.'" height="'.$iHeight.'" '.$sIframeAttr.'></iframe></div>', $sText ); /** * coub.com fixed */ $sText = preg_replace( '/<video>http(?:s|):\/\/(?:www\.|)coub\.com\/view\/(\w+).*<\/video>/i', '<div align="'.$iAlign.'"><iframe src="//coub.com/embed/$1?muted=false&autostart=false&originalSize=false&hideTopBar=false&noSiteButtons=false&startWithHD=false" width="'.$iWidth.'" height="'.$iHeight.'" '.$sIframeAttr.'></iframe></div>', $sText ); /** * ok.ru fixed */ $sText = preg_replace( '/<video>http(?:s|):\/\/(?:www\.|)ok\.ru\/video\/(\w+).*<\/video>/i', '<div align="'.$iAlign.'"><iframe src="//ok.ru/videoembed/$1" width="'.$iWidth.'" height="'.$iHeight.'" '.$sIframeAttr.'></iframe></div>', $sText ); /** * vk.com HASH not working, embeded link only */ $sText = preg_replace( '/<video>(https:\/\/(?:www\.|)vk\.com\/video_ext\.php.*)<\/video>/i', '<div align="'.$iAlign.'"><iframe src="$1" width="'.$iWidth.'" height="'.$iHeight.'" '.$sIframeAttr.'></iframe></div>', $sText ); /** * dailymotion.com fixed */ $sText = preg_replace( '/<video>http(?:s|):\/\/(?:www\.|)dai\.ly\/(\w+).*<\/video>/i', ' <div align="'.$iAlign.'"><iframe src="//dailymotion.com/embed/video/$1" width="'.$iWidth.'" height="'.$iHeight.'" '.$sIframeAttr.'></iframe></div>', $sText ); return $sText; }
Конечно же в /config/jevix.php добавляем нехватающие сайты.
Свои параметры сюда:
// Размеры и атрибуты окна вставленного видео. $iWidth = 620; $iHeight = 360; $iAlign = "center"; $sIframeAttr = 'frameborder="0" webkitAllowFullScreen mozallowfullscreen allowfullscreen="allowfullscreen"';
Готово!