Author Topic: Youtube video embeds are back  (Read 11205 times)

Offline Happy Cat

  • *
  • Posts: 3856
  • Total Meseta: 48
Youtube video embeds are back
« on: June 25, 2013, 02:26:40 pm »
Maybe you were wondering what happened to the youtube embeds we used to have. Well i upgraded the forum one day, and accidentally over wrote my script i made. and i couldn’t figure out how to do it again, well they are back finally, in a different way

this time they are parsed automatically so you don't have to press any weird buttons to go about press to make youtube videos embedded.

You need to have javascript enabled or else the URL's won't change to youtube videos for you. Big thanks to my friend ingolme for helping me out with the javascript and regular expressions, would of never gotten this done on my own. I was struggling so bad, heh

anyways, just paste a URL, and it works! (it wont work in previews though, you gotta post it to see it working)

http://www.youtube.com/watch?v=ygBA2GhLowA

you can go ahead and post a video in this topic to try it out if you want

Edit: Please note that the URL's won't change into videos if your browsing space is less then 960px wide.
« Last Edit: June 26, 2013, 11:14:20 am by Will »


Offline crackdude

  • *
  • Posts: 4256
  • Total Meseta: 64
  • Nintendo Bling
Re: Youtube video embeds are back
« Reply #2 on: June 25, 2013, 04:30:04 pm »
SEG4GES

Offline Happy Cat

  • *
  • Posts: 3856
  • Total Meseta: 48
Re: Youtube video embeds are back
« Reply #3 on: June 25, 2013, 05:19:30 pm »
hmm its quite annoying on mobile when you zoom in. makes it hard to scroll. will need to figure something out.

Offline Happy Cat

  • *
  • Posts: 3856
  • Total Meseta: 48
Re: Youtube video embeds are back
« Reply #4 on: June 25, 2013, 10:08:05 pm »
Okay I tweaked the video size, so they aren't as needlessly tall.

Also, if you are on a device with a resolution less then 960pixels wide for your browsing window space, the URL's won't convert over to videos.

Offline Barry the Nomad

  • *
  • Posts: 8806
  • Total Meseta: 713
  • Let's Post!
    • SEGAbits
Re: Youtube video embeds are back
« Reply #5 on: June 26, 2013, 08:28:58 am »

Offline Happy Cat

  • *
  • Posts: 3856
  • Total Meseta: 48
Re: Youtube video embeds are back
« Reply #6 on: June 26, 2013, 10:26:41 am »
Great stuff! Thanks Will!

Your welcome!

I've had to edit it yet again, noticed it was having problems with the window.onload function, like say just a minute ago barry's sig wasnt loading so the url's wouldn't convert over until his sig was fully loaded, but i found a solution

http://stackoverflow.com/a/16196548

Offline crackdude

  • *
  • Posts: 4256
  • Total Meseta: 64
  • Nintendo Bling
Re: Youtube video embeds are back
« Reply #7 on: June 26, 2013, 12:28:20 pm »
And the links show up below the videos! This is marvelous. Great job Will!
SEG4GES

Offline Happy Cat

  • *
  • Posts: 3856
  • Total Meseta: 48
Re: Youtube video embeds are back
« Reply #8 on: June 26, 2013, 01:07:16 pm »
And the links show up below the videos! This is marvelous. Great job Will!
Thanks!

I'm glad you like that little touch, I thought it would be nice incase anyone wanted to share a video elsewhere they could easily do it without having to click the video to open in a new window / tab. Also, I thought it would be nice to add in case someone is on a device that's width is is higher then 960 and can't support youtube videos, although that's very unlikely as most youtube videos are HTML5 supported now, but, still, was another reason I added it.

Sadly I can't make it clickable. I tried but the javascript freaks out. cause, what the script basically does is, captures the ID out of the URL with regular expressions, and then makes a new div element, and i got the youtube embed code inside that div element, and a variable for the video ID number. and i got the plain text URL under that. Then after that I tell javascript to delete the URL, so, that causes it to freak out and delete any URL associated with that youtube ID.

I don't know if i explained that very good xD, but i tried!