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

Need some help with media bbcode

Discussion in 'XenForo Questions and Support' started by Ray, Nov 5, 2010.

  1. Ray

    Ray Active Member

    Hello, everyone!

    I would like to add a custom bbcode. When entering the following bbcode:

    [video] video id [/video]

    I should see the video player plus a message "ID: video id" under the player.

    I know I have to edit the Base.php file, but don't really know what code I should use.


    <embed src="http://----.com/?v={$id}"></embed>
    br />
    b>ID: {$id}</b>
    As you can see, the first {$id} displays the player and the second {$id} outputs the ID in plain text.

    See screenshot


    Attached Files:

  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    You can add to the existing [media] BB code:

    Admin CP -> Home -> BB Code Media Sites

    Look at the existing media sites for code examples. It's fairly straight forward. Once you add your media site then you can use code like this in your post:


    Or you can click the Screen shot 2010-11-05 at 9.19.04 AM.png icon in the editor and paste the full URL.

    edit - here are some media sites people have added:

  3. Ray

    Ray Active Member

    That would work for new posts, but will take some time to edit 50k posts to reflect the new bbcode.

    The existing bbcode is [video] [/video]

    Do you know how I could update all the existing posts at once?

  4. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    A string replacement query might work for your purposes:

    UPDATE xf_post
    SET message = REPLACE(message, '[video]', '[media=youtube]')

    UPDATE xf_post
    SET message = REPLACE(message, '[/video]', '[/media]')

    Backup first.
    Ray likes this.
  5. Brogan

    Brogan XenForo Moderator Staff Member

    Ray and Jake Bunce like this.
  6. Ray

    Ray Active Member

    Thanks, guys! :D

Share This Page