0

I am using the excellent bit of code at https://stackoverflow.com/a/5831191/797620 to help convert multiple youtube links to a consistant syntax, and I have found multiple means of converting a single youtube link within a block of text to work, but what I cannot figure out (nor find) is how to convert multiple youtube video links to embed the videos inline.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce nulla urna, sagittis at massa id, lobortis eleifend nisi. Quisque ac purus nunc. Vivamus mollis lorem in vulputate aliquam. Nunc iaculis tincidunt rhoncus. In hac habitasse platea dictumst. Donec molestie risus ut dolor tristique, in ornare ipsum ultrices. http://www.youtube.com/watch?v=UF8uR6Z6KLc Maecenas nec quam ac enim commodo egestas nec vulputate massa. Praesent malesuada, diam molestie suscipit dictum, sapien magna dictum magna, non dapibus lacus nulla ac est. Maecenas id nunc nisl. Proin accumsan aliquet felis, eget porta est malesuada eget. Fusce pharetra condimentum sapien, eget ornare ipsum. http://youtu.be/UF8uR6Z6KLc Fusce sed metus ut nisi iaculis cursus nec eget dui. Aliquam volutpat nisi non est egestas, pretium ullamcorper lectus commodo. Duis ac congue elit. Mauris laoreet turpis quis massa tempor, vitae sodales metus mattis. Ut quis ornare ligula. Nullam id cursus lectus, eget molestie mauris. Morbi lacinia, mauris at dictum tincidunt, est leo pharetra ligula, in egestas velit sem vel nunc. Fusce adipiscing, risus vel viverra hendrerit, mi odio iaculis dui, et pharetra turpis ipsum vel dui. Maecenas porta varius laoreet. Donec bibendum quis mi quis egestas. Vivamus vitae suscipit erat. Maecenas sollicitudin, libero quis aliquam cursus, leo urna vulputate nibh, ut pellentesque arcu lectus in felis. http://youtu.be/UF8uR6Z6KLc Phasellus facilisis, justo quis faucibus accumsan, lorem dolor ornare diam, sit amet semper leo justo vitae erat. Duis eu leo in massa mollis rhoncus sit amet id metus. Integer vel sodales ligula, sed molestie tellus. Nunc at tellus a ante vestibulum placerat.

What I am wanting is to have all three of the links to the youtube videos be displayed inline (not at the end of the block of text) as actual iframe embedded videos.

Thanks!

Community
  • 1
  • 1
Abela
  • 1,225
  • 3
  • 19
  • 42

1 Answers1

1

Change that same function you were given, where you see '<a href="http://www.youtube.com/watch?v=$1>YouTube link: $1</a>', to:

'<iframe title="$1" frameborder="0" scrolling="no" src="http://www.youtube.com/embed/$1"></iframe>';

I would of course, change the function name. Maybe you should add a title argument, as well, and change the $1 part of title="$1"`.

StackSlave
  • 10,613
  • 2
  • 18
  • 35
  • OMG... issue an "idiot" alert for this one. SIGH. Too many hours looking at code and the obvious smacks you in the face. Thanks glue! – Abela Jul 13 '13 at 00:57