You Tube Links in 3.1.9 Board

Get help with installation and running phpBB 3.1.x here. Please do not post bug reports, feature requests, or extension related questions here.
Scam Warning
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTE: phpBB 3.1.x is at its End of Life stage and support will NOT be provided after July 1st, 2018.
Locked
kfs
Registered User
Posts: 7
Joined: Thu Jul 14, 2016 12:17 pm

You Tube Links in 3.1.9 Board

Post by kfs » Thu Aug 18, 2016 7:42 pm

I realized that all of the complaints and attempted fixes have been posted in the 3.0 forum. I tried them all but none of them worked.

I was using this code before the trouble came down.....

Code: Select all

[youtube]{SIMPLETEXT}[/youtube]


<object type="application/x-shockwave-flash" style="width:525px; height:450px;" data="http://www.youtube.com/v/{SIMPLETEXT}"><param name="movie" value="http://www.youtube.com/v/{SIMPLETEXT}" /></object>


Enter the youtube video id only. Example - youtu.be/b_HwkBHyXZ8  use just the b_HwkBHyXZ8
This code continued to work with Firefox but none of the other browsers such as IE and Chrome.

I removed the bbcode and loaded JoshYs SE9 which worked great as far as today forward.

I am looking for a bbcode that I can repost for a 3.1.9 board that with reactivate my older prior posted videos without having to manually update.

The old code allowed for just the video id to be placed between the youtube brackets to embed the video.

Thanks in advance

User avatar
k0nsl
Registered User
Posts: 89
Joined: Mon Mar 25, 2013 11:17 pm
Location: Scandinavia
Name: Eduard Drehner
Contact:

Re: You Tube Links in 3.1.9 Board

Post by k0nsl » Thu Aug 18, 2016 10:44 pm

Well, first of all: don't use Flash when HTML5 is available and supported by practically every browser of note :)

Secondly, here is the solution I've got for one of my boards. It probably can do with some tweaking and a general overhaul, but for the moment it's "working" and it has been working for the past 2+ years or so.

File: yt_embed.php

Code: Select all

<?php
//Simple code for returning an "embed" link, for youtube.
//works mostly with the iframe method.

if(isset($_GET['url'])) {
$url = $_GET['url'];

if (filter_var($url, FILTER_VALIDATE_URL)) {

//Strip out the url itself,

$url = str_replace('http://', "", $url);
$url = str_replace('https://', "", $url);
$url = str_replace('www.', "", $url);
//
$url = str_replace('youtube.com/watch?v=', "", $url);
$url = str_replace('youtube.com/v/', "", $url);
$url = str_replace('youtu.be/', "", $url);

//probably in effecient, but i'm too lazy to look up a better way.. so...
$params = explode('&', $url);
$embed = $params[0];
$params = explode('?', $embed);
$embed = $params[0];
//Basically, it'll split the remnants by the "&"s found in the string. We only need the first instance, as the rest
//are just arguements for the video, that aren't compatible in this form.

header('Location: https://www.youtube.com/embed/'.$embed );
//and viola!

}
else
  {
  echo "URL is invalid.";
  }

};
?>
Paste: https://p.k0nsl.org/?d5b320612d6ad0fa#/ ... b047Pw3wY=

Usage:

Code: Select all

[youtube]{TEXT}[/youtube]
HTML replacement:

Code: Select all

<iframe width="420" height="315" src="/yt_embed.php?url={TEXT}" frameborder="0" border="0" cellspacing="0" style="border-style: none"></iframe>
This method can be taxing on resources. If anyone can improve on it, go ahead. The author is somewhere on this board, I forgot who it was!

Best wishes,
-k0nsl
I'm a programmer, server administrator, designer, spokesman and factotum of a wide-variety of web pages.

Locked

Return to “[3.1.x] Support Forum”