Page 1 of 1

Videos from Facebook or YouTube

Posted: Thu Apr 18, 2019 6:55 am
by EYUman
Hi there

I am looking for a way to make videos run on FlatPress .. until now, noting works.

Thanks in advance for any answer.

Re: Videos from Facebook or YouTube

Posted: Sat Apr 20, 2019 11:20 am
by Arvid
Hi, welcome to the FlatPress support forum :)

I have no experiences with Facebook videos (anyone else?), but as for Youtube, it's as simple as that:

Code: Select all

See also the BBCode documentation on our wiki:


Re: Videos from Facebook or YouTube

Posted: Sun Apr 21, 2019 10:25 am
by vodka
Replace the script from line 332 in fp-plugin/bbcode/plugin.bbcode.php with this

Code: Select all

function do_bbcode_video($action, $attr, $content, $params, $node_object) {
	if ($action == 'validate') {
		return true;
	$vurl = parse_url($attr['default']);
	if (isset($attr['type'])) {
		$type = $attr['type'];
	} else {
		// is it  or ?
		$web = explode('.', $vurl['host']);
		$type = isset($web[1])
			? $web[1]
			: $web[0];
		$color = isset($attr['color'])
			? $attr['color']
			: '';
		$width = isset($attr['width'])
			? $attr['width']
			: '560';
		$height = isset($attr['height'])
			? $attr['height']
			: '315';
		$allowfs = isset($attr['allowfullscreen'])
			? $attr['height']
			: 'allowfullscreen';			
		$float = isset($attr['float'])
			? "align=\"{$attr['float']}\" "
			: "style=\"margin: 0 auto; display:block;\" ";

	$query = utils_kexplode($vurl['query'], '=&');
	$the_url = null;
	$others = '';
	switch ($type) {
		case 'html5':
			$the_url = "<video style=\"display:block; margin: 0 auto;\" width=\"{$width}\" height=\"{$height}\" controls>"
				."<source src=\"".$attr['default']."\">"
				."Your browser does not support the video tag."
		case 'youtube':
			$the_url = "<iframe src=\"{$query['v']}\" width=\"{$width}\" height=\"{$height}\" frameborder=\"0\" allow=\"accelerometer; autoplay; fullscreen; encrypted-media; gyroscope; picture-in-picture\" {$float}></iframe>";
		case 'vimeo':
			$vid = isset($query['sec'])? $query['sec'] : str_replace('/', '', $vurl['path']);
			$the_url="<iframe src=\"{$vid}?color={$vid}&title=0&byline=0&portrait=0\" width=\"{$width}\" height=\"{$height}\" frameborder=\"0\" allow=\"autoplay; fullscreen;\" allowfullscreen {$float}></iframe>";
		case 'facebook':
			$vid = isset($query['sec'])? $query['sec'] : str_replace('/video/', '', $vurl['path']);
			$the_url="<div id=\"fb-root\"></div>
			<script async defer src=\"\"></script>
			<div class=\"fb-video\" data-href=\"{$vid}\" data-allowfullscreen=\"true\" data-width=\"{$width}\"></div>";
		case 'default':
			$the_url = null;

	if ($the_url) {
		return $the_url;
	return '[unsupported video]';
You have support for youtube, vimeo, facebook and html5 (for mp4 you must set the type like in the exemple).

Code: Select all




[video= type=html5]




I hope to find a way to auto recognize html5 videos and I will send all in github.

Re: Videos from Facebook or YouTube

Posted: Mon Jul 01, 2019 4:38 pm
by B-d-R-D
Hello there, hello vodka,

I replaced the script from line 332 in fp-plugin/bbcode/plugin.bbcode.php with your code and I got Error 500...
Nothing to see anymore behalve the Error 500 script error ..

Whats wong now?
I installed the flatpress-master which was offered here in an other thread .. :
Re: White screen after setup of Flatpress
Beitrag von Lubomír Ludvík » Mi Feb 20, 2019 9:05 pm

try dev version 1.1 ...
And now I try to get my website running again ... :roll:

Well, I changed it back to the origin file, now the website is running again, but there is no possibility to run any other video URL than You Tube.


Re: Videos from Facebook or YouTube

Posted: Mon Jul 08, 2019 10:50 pm
by vodka
You must replace only the lines for the function (from 332 to 373)

Re: Videos from Facebook or YouTube

Posted: Sat Sep 21, 2019 6:05 pm
by rhays
Thanks, Vodka!

Modified code as stated, and works well. Thanks for the patch.


Re: Videos from Facebook or YouTube

Posted: Mon Oct 07, 2019 3:07 pm
by Arvid
Thank you vodka, this is very useful. I slightly adapted your code and added it to the FP sources.

To be mentioned: It does not support uploaded video files yet - please refer to the the Audio and video player plugin in this case. Maybe we could unify this later.