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 ArticleAnswer 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 ArticleAnswer 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 ArticleAnswer 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 ArticleAnswer 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 ArticleAnswer 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 ArticleAnswer 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 ArticleAnswer 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 ArticleAnswer 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 ArticleAnswer 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 ArticleAnswer 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 ArticleConvert 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
More Pages to Explore .....