• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XF 1.1 Issue with youtube links

mono

Active member
#1
Hi. After import from vB 3.8 all youtube links in messages haven't converted into window look. It could be done if you edit and save message without editing. Could anyone suggest what can I do with this?
Example:
 

Attachments

Jake Bunce

XenForo moderator
Staff member
#2
I can't see the BB code in that screenshot, but I assume it's a plain URL tag with no option.

For a replacement like that you can use this addon:

http://xenforo.com/community/threads/post-content-find-replace.6548/

Here are settings for your replacement:

Quick Find: youtube.com

Regular expression: #\[url\]http:.+youtube\.com.+v=([a-zA-Z0-9_\-]+?).*\[/url\]#siU

Replacement String: [media=youtube]\1[/media]
 

Jake Bunce

XenForo moderator
Staff member
#3
And you will no doubt encounter errors regarding this setting:

Admin CP -> Home -> Options -> Messages -> Maximum Media Embeds per Message

You should increase it.
 

mono

Active member
#4
Thank you very much, Jake for this detailed explanaton. I get this error when going to Tools -> Replace in Posts:
Code:
A controller for the route path post-replace/ was not found.
 
Last edited:

mono

Active member
#8
Yes, Jake, you were right. It works now and all links seem converted correctly. Maybe it would be useful to note in the resource description where exactly add-on folder should be? Thank you for your help!
 
#9
I can't see the BB code in that screenshot, but I assume it's a plain URL tag with no option.

For a replacement like that you can use this addon:

http://xenforo.com/community/threads/post-content-find-replace.6548/

Here are settings for your replacement:

Quick Find: youtube.com

Regular expression: #\[url\]http:.+youtube\.com.+v=([a-zA-Z0-9_\-]+?).*\[/url\]#siU

Replacement String: [media=youtube]\1[/media]
Sorry to bump an old thread but it's difficult to narrow down to specifically what I'm looking to do, and this is the closest yet.

Ran the above, worked. Thanks!

Also wondering how we can run this for links like:

Code:
[url="http(s)://www.youtube.com/WHATEVER"]SOMETHING WHATEVER[/url]
Upper / lowercase url bbcode, with/without quotes, etc.

I don't have/use any [ame] or [youtube] or [yt] code floating around, we just used "paste a link and it will work" style on vB until the move.
 

Jake Bunce

XenForo moderator
Staff member
#10
@alex2k5

Youtube links come in lots of different formats. I don't have one regex to do them all. I always end up looking for exceptions and modifying the rule to handle each one.

If you can provide a specific example then I can provide the regex.
 
#11
Just looking for the basic one above, but for bbcode

Code:
[url=''] [/url]
rather than

Code:
[url] [/url]
The youtube part of your regular expression above should be fine. Catches the most common:

Code:
http://www.youtube.com/watch?v=XXXX
Thanks for looking into it, appreciated.
 

Jake Bunce

XenForo moderator
Staff member
#12
Try this. I tightened up the matching a bit and changed it to look for that new url tag format:

Quick Find: youtube.com

Regular expression: #\[url="http:[^"\]]+youtube\.com[^"\]]+v=([a-zA-Z0-9_\-]+?)[^"\]]*"\][^\[]+\[/url\]#siU

Replacement String: [media=youtube]\1[/media]