1. 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

Discussion in 'Installation, Upgrade, and Import Support' started by mono, Aug 11, 2013.

  1. mono

    mono Active Member

    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:
     

    Attached Files:

  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    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]
     
    alex2k5, Jakob Eissler and mono like this.
  3. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    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 likes this.
  4. mono

    mono Active Member

    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: Aug 12, 2013
  5. Jeremy

    Jeremy XenForo Moderator Staff Member

    You may want to attempt to reinstall the add-on.
     
  6. mono

    mono Active Member

    Tried. Didn't help.
     
  7. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    You probably uploaded the files incorrectly. This directory should exist on your server:

    library/PostReplace
     
  8. mono

    mono Active Member

    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. alex2k5

    alex2k5 Member

    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.
     
  10. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    @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. alex2k5

    alex2k5 Member

    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.
     
  12. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    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]
     

Share This Page