Jump to content

Embed YouTube Video - New Button in Toolbar


Rikifive

Recommended Posts

(edited)

It's not a common problem, but rarely, users mention, that the editor refuses to convert a link into a video embed when trying to share YouTube videos.

Unfortunately, by default, when the editor refuses to cooperate like this, there aren't really any ways to work around it and force it to turn links into embedded videos.

So as an experiment, I have programmed my first, little actual plugin where I can use JavaScript, that hopefully should help with that.

 

I have added a button to the editor's toolbar between "code" and "spoiler" buttons:

238vbj658sm.png

Clicking this button will ask for a YouTube video link. When a valid link is provided, it should directly insert the embedded video into the post.

 

It is currently available only on small (phone) and medium (tablet) displays, as that's where I believe this problem likes to happen, depending on device and browser. I suspect this issue doesn't happen on PC's, or at least not as often, so for the time being I haven't added that button on large displays, unless users will wish to have it there too.

 

One thing to note though:

The video link should contain the video's ID, consisting of 11 characters. That's the only information it has to extract from the link for it to work.

YouTube tends to give links with different formats (like some "youtu.be" stuff), but I used a regular expression to hopefully capture that ID from all of them.

If at any point anyone gets an error, despite providing a seemingly valid link, please poke me or simply reply here, so that I can adjust the code. :darling:

 

Let me know if it's helpful or not! :mlp_icwudt:

Edited by Rikifive
  • Brohoof 1
  • Thanks 1

 ■■■■■■■■■■
 ■■■■■■■■■■

Link to comment
Share on other sites

(edited)

And there I was a few months ago wondering how to embed a video because there was no button until I figured it out. mlp-tderp.png.2a12a9171ec5a16142cfd2dfad393b93.png Having it happen automatically was not something I was used to, I think it'll be helpful. mlp-tclapfixed.gif.66610c95cd21f9a426ddc5acbb2b2cdb.gif

Edited by Acinonyx
  • Excited 1

nature2.png.bf15f5dbcc42fcaa2e5d5026fddbb9b3.png

 

Link to comment
Share on other sites

bigly!!! :3 this is neat. i was wondering the other day how i was meant to embed videos on mobile (it was not showing up in the preview) and now i do not have to wonder anymore uwu

  • Excited 1
Link to comment
Share on other sites

Thank you for your input everyone! :twilightsmile:

  • Brohoof 1

 ■■■■■■■■■■
 ■■■■■■■■■■

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Join the herd!

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...