Replacing old custom YOUTUBE BBcode in posts

Ingenious

Well-known member
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? :)
 
  • Like
Reactions: DOA
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.
 
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?
 
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!
 
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.
 
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.
How made bbcode for this:

Code:
[video=youtube;cPVgwz5aN1o]https://www.youtube.com/watch?v=cPVgwz5aN1o[/video]
 
Top Bottom