Quantcast
Channel: Convert a YouTube video URL to embed code - Stack Overflow
Browsing latest articles
Browse All 12 View Live

Answer by OneScriptMan for Convert a YouTube video URL to embed code

Created a Angular pipe for this case, which can simply be used wherever needed, it converts the link directly in the template.HTML template:<iframe width="560" height="315"...

View Article



Answer by Reuben B for Convert a YouTube video URL to embed code

Doesn't this way of getting the embedded id from desktop links seem easier to understand? const convertLinkToEmbedId = () => { const link = "https://www.youtube.com/watch?v=gBrmnB5aOSI&...";...

View Article

Answer by mate.gvo for Convert a YouTube video URL to embed code

I think the simplest solution is this:ytUrl = "https://www.youtube.com/watch?v=DGIXT7ce3vQ"// replace:ytUrl.replace('/watch?v=', '/embed/')

View Article

Answer by BiGBaDWolF for Convert a YouTube video URL to embed code

@if (path.Contains('&')) path = path.Split('&')[0];<iframe width="690" height="400" src="@Model.YourModelNameHERE.Replace("watch?v=","embed/")" frameborder="0"...

View Article

Answer by OzzyCzech for Convert a YouTube video URL to embed code

Who needs jQuery. Below is pure javascript code using URL() function to get v parameter from YouTube URL and insertAdjacentHTML() from replacing current <script> tag with...

View Article


Answer by SAUMITRA KUMAR for Convert a YouTube video URL to embed code

This works fine for me on ReactJS<iframe src={`https://www.youtube.com/embed/${url.split('='}[1]&autoplay=false`} controls allowfullscreen />

View Article

Answer by Ashwin Valento for Convert a YouTube video URL to embed code

You can get the embed code by using the oembed API. There may be multiple variants of the YouTube URL and using regex may not be an optimal...

View Article

Answer by VishalParkash for Convert a YouTube video URL to embed code

Here is what I used to convert the YouTube URL to embed and make the video work.<script> function myFunction() { var str = "https://www.youtube.com/watch?v=1adfD9"; var res = str.split("="); var...

View Article


Answer by phlare for Convert a YouTube video URL to embed code

I've been using this pair of functions to convert youtube links in a block of html from a wysiwyg editor into embedded iframes.As with other solutions, this can still mangle some other html in the...

View Article


Answer by Jim Infantino for Convert a YouTube video URL to embed code

function popYouTubeId(buttonid) { var youTubeUrl = $(buttonid).attr('data-url'); var youTubeId; var regExp = /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/; var match =...

View Article

Answer by isherwood for Convert a YouTube video URL to embed code

I'd be inclined to simply grab the video ID per this question and use it to formulate your embed markup as you like. http://jsfiddle.net/isherwood/cH6e8/function getId(url) { const regExp =...

View Article

Convert a YouTube video URL to embed code

I'm using this to convert YouTube URL to embed URL.text(t).html().replace(/(?:http:\/\/)?(?:www\.)?(?:youtube\.com)\/(?:watch\?v=)?(.+)/g, '<iframe width="320" height="280"...

View Article
Browsing latest articles
Browse All 12 View Live




Latest Images