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

Replacing old custom YOUTUBE BBcode in posts

Ingenious

Well-known member
#1
In my imported forum, all YouTube videos are embedded in posts using some custom BBcode, because otherwise vB just displayed a link to the video and not embed the actual video. So my forum posts are full of:

[YOUTUBE]videocode[/YOUTUBE]

Is there an easy way I can do a search and replace on these as follows:

find [YOUTUBE]$string[/YOUTUBE]
replace with

Code:
http://www.youtube.com/watch?v=$string
I'm sure I read somewhere you can do a search and replace but I cannot for the life of me find this now. I can't see any options either in XenForo admin or vB admin to run a search and replace query like this.

Any ideas please? :)
 

Brogan

XenForo moderator
Staff member
#2
Take a backup first.

Code:
UPDATE xf_post SET message = REPLACE(message, '[youtube]', '[media=youtube]');
UPDATE xf_post SET message = REPLACE(message, '[/youtube]', '[/media]');
That will embed all videos, assuming just the video ID is between the existing youtube tags.
 
#4
In my imported forum, all YouTube videos are embedded in posts using some custom BBcode, because otherwise vB just displayed a link to the video and not embed the actual video. So my forum posts are full of:

[YOUTUBE]videocode[/YOUTUBE]

Is there an easy way I can do a search and replace on these as follows:

find [YOUTUBE]$string[/YOUTUBE]
replace with

Code:
http://www.youtube.com/watch?v=$string
I'm sure I read somewhere you can do a search and replace but I cannot for the life of me find this now. I can't see any options either in XenForo admin or vB admin to run a search and replace query like this.

Any ideas please? :)
I also had the same problem
[YOUTUBE;$string]$string[/YOUTUBE]
Code:
http://www.youtube.com/watch?v=$string
Can I replace all the orders one?
 
#6
Take a backup first.

Code:
UPDATE xf_post SET message = REPLACE(message, '[youtube]', '[media=youtube]');
UPDATE xf_post SET message = REPLACE(message, '[/youtube]', '[/media]');
That will embed all videos, assuming just the video ID is between the existing youtube tags.
This was really helpful :), there was some old custom vbulletin youtube tags didn't change using this add-on

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

This was fast, accurate and save, but always remember to do backup before you play with the database!
 
#7
Of course, you could easily just create a custom xenforo youtube bbcode.
Code:
<iframe width="500" height="300" src="https://www.youtube.com/embed/{text}?wmode=opaque" frameborder="0" allowfullscreen></iframe>
Simple replacement, no parameter.