Videos on youtube usually have a URI such as the following:
These URIs cannot be used to embed the video in an iframe such as the following:
In order to work as part of an embedded iframe, youtube video links must be in the following format:
Luckily, given any ‘normal’ youtube link, it is very easy to generate such an embed link. In JavaScript, this can be done with the following function:
function createYouTubeEmbedLink (link) { return link.replace("http://www.youtube.com/watch?v=", "http://www.youtube.com/embed/"); }
Hello my friend! I wish to say that this article is amazing, nice written and come with approximately all important infos.
I would like to see more posts like this .
A really old and slow, computer illiterate person like me cannot follow technical language readily taken for granted by those in the ‘know. I would love to have step by step instructions to link a YouTube video to one word in my comment to someone else’s blog.
When you posted:
“Luckily, given any ‘normal’ youtube link, it is very easy to generate such an embed link. In JavaScript, this can be done with the following function:
1
function createYouTubeEmbedLink (link) {
2
return link.replace(“http://www.youtube.com/watch?v=”, “http://www.youtube.com/embed/”);
3
}
”
I haven’t a clue what you are talking about. I know how to copy the YouTube URL but how do I go to JavaScript (?) in order to complete the following steps of your instructions?
Hi pentugal,
you don’t need JavaScript to link to a video on YouTube! Just take the link as it is (from YouTube) and paste the link into the comment/post.
The post above is about a problem one might encounter when developing a JavaScript application – therefore the technical language!
Cheers,
Max
Thank you.
Now how can i use this code to replace src attribute inside iframe? I pasted javascript code but now working.
This is my iframe code
But is not been replaced to
Any solution?
Hello and thank you for your comment! It looks like WP removed the sample code you have provided!
How to make it work in drupal?
Sorry I am not familiar with drupal!