youtube urls - Replace youtube tags with iframe tags Hitskin_logo Hitskin.com

This is a Hitskin.com skin preview
Install the skinReturn to the skin page

The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.
3 posters

    Replace youtube tags with iframe tags

    TheCrow
    TheCrow
    Manager
    Manager


    Male Posts : 6923
    Reputation : 795
    Language : Greek, English

    youtube urls - Replace youtube tags with iframe tags Empty Replace youtube tags with iframe tags

    Post by TheCrow May 16th 2016, 2:05 pm

    Hello dear all,

    I want a code for my editor that will replace the youtube tags with the iframes tags.
    What i mean is:
    When i want to add a youtube video in my posts i add it through the youtube icon and it takes the part after the / and adds it in [youtube] tags. Like this:
    Code:
    [youtube]c7nRTF2SowQ[/youtube]


    Now those c7nRTF2SowQ are the key letters for the iframe too. So what i want is a code that will replace
    Code:
    [youtube]
    with
    Code:
    <iframe width="560" height="315" src="https://www.youtube.com/embed/
    and
    Code:
    [/youtube]
    with
    Code:
    " frameborder="0" allowfullscreen></iframe>

    Is there any code that will help me to that?



    The alternative way would be a code that will replace the [youtube] tags after the post was sent and change them into the iframe tags i wrote above.

    Any of these would be perfect!!

    Thanks for your time and much appreciation for those who help!


    My forum details:
    Forum Link: http://www.thinktankforum.net
    Forum Version: Phpbb3


    Luffy :rose:


    Last edited by Luffy on May 16th 2016, 6:14 pm; edited 1 time in total
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13246
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    youtube urls - Replace youtube tags with iframe tags Empty Re: Replace youtube tags with iframe tags

    Post by Ange Tuteur May 16th 2016, 4:45 pm

    @Luffy try installing the following script in all the pages.
    Code:
    $(function() {
      for (var a = $('embed[src*="youtube"]'), i = 0, j = a.length; i < j; i++) {
        a[i].insertAdjacentHTML('beforebegin', '<iframe width="560" height="315" src="' + a[i].src + '" frameborder="0" allowfullscreen></iframe>');
        a[i].parentNode.removeChild(a[i]);
      }
    });
    It'll replace the embed elements with iframes.
    TheCrow
    TheCrow
    Manager
    Manager


    Male Posts : 6923
    Reputation : 795
    Language : Greek, English

    youtube urls - Replace youtube tags with iframe tags Empty Re: Replace youtube tags with iframe tags

    Post by TheCrow May 16th 2016, 6:15 pm

    Thank you @Ange Tuteur. That was exactly what i wanted! Smile



    youtube urls - Replace youtube tags with iframe tags Thecro10
    Forum of the Forums

    Forumotion Rules | Tips & Tricks |
    FAQ | Did you forget your password?



    *** The Support Forum will never ask you for your email or password, so please do not post them anywhere! ***
    No support via PM!
    brandon_g
    brandon_g
    Manager
    Manager


    Male Posts : 10112
    Reputation : 923
    Language : English
    Location : USA

    youtube urls - Replace youtube tags with iframe tags Empty Re: Replace youtube tags with iframe tags

    Post by brandon_g May 16th 2016, 6:29 pm

    Thanks again for the help Ange. Smile

    Topic solved and archived ~ brandon_g



    youtube urls - Replace youtube tags with iframe tags Brando10
    Remember to mark your topic youtube urls - Replace youtube tags with iframe tags Solved15 when a solution is found.
    General Rules | Tips & Tricks | FAQ | Forgot Founder Password?

    youtube urls - Replace youtube tags with iframe tags Scre1476
    Team Leader
    Review Section Rules | Request A Review | Sticker Points
    brandon_g
    brandon_g
    Manager
    Manager


    Male Posts : 10112
    Reputation : 923
    Language : English
    Location : USA

    youtube urls - Replace youtube tags with iframe tags Empty Re: Replace youtube tags with iframe tags

    Post by brandon_g May 24th 2016, 12:55 pm

    Topic re-opened on topic starter request ~ brandon_g



    youtube urls - Replace youtube tags with iframe tags Brando10
    Remember to mark your topic youtube urls - Replace youtube tags with iframe tags Solved15 when a solution is found.
    General Rules | Tips & Tricks | FAQ | Forgot Founder Password?

    youtube urls - Replace youtube tags with iframe tags Scre1476
    Team Leader
    Review Section Rules | Request A Review | Sticker Points
    TheCrow
    TheCrow
    Manager
    Manager


    Male Posts : 6923
    Reputation : 795
    Language : Greek, English

    youtube urls - Replace youtube tags with iframe tags Empty Re: Replace youtube tags with iframe tags

    Post by TheCrow May 24th 2016, 1:10 pm

    Hello and thank you brandon for re-opening the topic,

    So the code @Ange Tuteur gave me works fine but it's not actually the one i posted on the first post.
    The iframe on the first post has a src of "http://youtube.com/embed/Video Url" and the rest.. The code i have now simple changes the simple youtube frame to the iframe with that width. Is there any way we could change it to the actual iframe because when i tried to add the src in the js it showed me an error to the video. I suppose it's the "embed" word in the link (?) because it replaces the embed (?) Think

    Thanks for your help! Smile



    youtube urls - Replace youtube tags with iframe tags Thecro10
    Forum of the Forums

    Forumotion Rules | Tips & Tricks |
    FAQ | Did you forget your password?



    *** The Support Forum will never ask you for your email or password, so please do not post them anywhere! ***
    No support via PM!
    TheCrow
    TheCrow
    Manager
    Manager


    Male Posts : 6923
    Reputation : 795
    Language : Greek, English

    youtube urls - Replace youtube tags with iframe tags Empty Re: Replace youtube tags with iframe tags

    Post by TheCrow May 29th 2016, 5:20 pm

    Bump.



    youtube urls - Replace youtube tags with iframe tags Thecro10
    Forum of the Forums

    Forumotion Rules | Tips & Tricks |
    FAQ | Did you forget your password?



    *** The Support Forum will never ask you for your email or password, so please do not post them anywhere! ***
    No support via PM!