Youtube tag should support both http://www and www URL form

Have any ideas for improvements? Run into any bugs? Let us know here.
Post Reply
Posts: 963
Joined: June 2009
Hi Alex,

I think generally that this is a usability bug. Requiring http:// for the youtube link to work seems kind of anal even though I understand how easy it is to include it. I just thought I'd let you know.

Regards.

User avatar
Posts: 1424
Joined: January 2009
Location: Cupertino, CA
Our YouTube tag strips the video ID from the URL and inserts it into the embedded HTML using the {TEXT} token in the string.

This:

Code: Select all

[youtube]http://www.youtube.com/watch?v={TEXT}[/youtube]
To this:

Code: Select all

<iframe title="YouTube video player" width="736" height="444" src="http://www.youtube.com/embed/{TEXT}?hd=1" frameborder="0" allowfullscreen></iframe>
If any part of the URL is missing, like the "http://" bit, then BBcode thinks you have the wrong format and it won't display the video. It doesn't look clear to me if I can add conditional statements in these codes. I would love to fix this issue and do something like this...

Code: Select all

[youtube]http://www.youtube.com/watch?v={TEXT}[/youtube]
OR
[youtube]www.youtube.com/watch?v={TEXT}[/youtube]
But I don't think this would work.

Posts: 963
Joined: June 2009
AlexHaas wrote:Our YouTube tag strips the video ID from the URL and inserts it into the embedded HTML using the {TEXT} token in the string.

This:

Code: Select all

[youtube]http://www.youtube.com/watch?v={TEXT}[/youtube]
To this:

Code: Select all

<iframe title="YouTube video player" width="736" height="444" src="http://www.youtube.com/embed/{TEXT}?hd=1" frameborder="0" allowfullscreen></iframe>
If any part of the URL is missing, like the "http://" bit, then BBcode thinks you have the wrong format and it won't display the video. It doesn't look clear to me if I can add conditional statements in these codes. I would love to fix this issue and do something like this...

Code: Select all

[youtube]http://www.youtube.com/watch?v={TEXT}[/youtube]
OR
[youtube]www.youtube.com/watch?v={TEXT}[/youtube]
But I don't think this would work.
I'm thinking this is running through regular expression, so you should be able to do something optional with the string used by the youtube tag.

Is there some API for BBCode?

User avatar
Posts: 1424
Joined: January 2009
Location: Cupertino, CA
niniendowarrior wrote:I'm thinking this is running through regular expression, so you should be able to do something optional with the string used by the youtube tag.

Is there some API for BBCode?
It's definitely using some sort of regular expression thing to parse the string.

I'm not sure if there's an API for BBCode.

Posts: 963
Joined: June 2009
AlexHaas wrote:
niniendowarrior wrote:I'm thinking this is running through regular expression, so you should be able to do something optional with the string used by the youtube tag.

Is there some API for BBCode?
It's definitely using some sort of regular expression thing to parse the string.

I'm not sure if there's an API for BBCode.
I'm not exactly grasping how the youtube tags were implemented. Can you put up a link on its implementation? I'm pretty sure it should be possible to do something like:

Code: Select all

(http://){0,1}www.youtube.com/watch?v={TEXT}

User avatar
Posts: 1424
Joined: January 2009
Location: Cupertino, CA
niniendowarrior wrote:

Code: Select all

(http://){0,1}www.youtube.com/watch?v={TEXT}
I just ran a test and this bit doesn't work. :(

Posts: 963
Joined: June 2009
AlexHaas wrote:
niniendowarrior wrote:

Code: Select all

(http://){0,1}www.youtube.com/watch?v={TEXT}
I just ran a test and this bit doesn't work. :(
Hmm... do you know what php function is being used on your youtube code pattern?

Posts: 963
Joined: June 2009

Post Reply