question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Youtube embed video link

See original GitHub issue

Hi. I try insert embed YT video link like “http://www.youtube.com/embed/uz8NDWopZyU” with iframe

$.magnificPopup.open({
                        items: {
                            src: video,
                            type:'iframe'
                        },
                    })

But YT return error. In the html of iframe tag I’ll see next link:

<iframe class="mfp-iframe" src="//www.youtube.com/embed/http://www.youtube.com/embed/uz8NDWopZyU?autoplay=1" frameborder="0" allowfullscreen=""></iframe>

In advance I don’t know what the link is.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:8

github_iconTop GitHub Comments

4reactions
WJakubcommented, Mar 6, 2018

Late to the party, in case someone needs to use the actual embed URL for Magnific, here is my process:

  • Write a function that gets the input URL, checks it’s format and then ensures that the /embed/ url is returned.
  • In Magnific markup always use the processed URL which is in the embed format.
  • Add the following patterns to magnific, to essentially use the input URL as the url without processing it further:
// Video popup, Backend enforces embed URL before it gets here.
    $('.js-popup-video').magnificPopup({
        type: 'iframe',
        iframe: {
            patterns: {
                youtube: {
                    index: 'youtube.com/',
                    id: function (url) { return url },
                    src: '%id%'
                },
                vimeo: {
                    index: 'vimeo.com/',
                    id: function (url) { return url },
                    src: '%id%'
                }
            }
        }
    });
1reaction
cyberwanicommented, Feb 29, 2020

This solution will work best for all YouTube link patterns. https://stackoverflow.com/a/48696208

Read more comments on GitHub >

github_iconTop Results From Across the Web

Embed videos & playlists - YouTube Help - Google Support
Embed a video or playlist · On a computer, go to the YouTube video or playlist you want to embed. · Click SHARE...
Read more >
How to get the Embed URL/Link of a Youtube Video
Simply click on the “share” link while on the youtube video page then click on “embed”. Now you can grab the correct url/link...
Read more >
HTML YouTube Videos - W3Schools
Upload the video to YouTube · Take a note of the video id · Define an <iframe> element in your web page ·...
Read more >
YouTube Embedded Players and Player Parameters
For an IFrame embed, the YouTube video ID for the video that you want to load is specified in the IFrame's src URL....
Read more >
How to Embed Youtube Videos: A Step-by-Step Guide
Go to the YouTube page, select a video, and click on the 'Share' option that is displayed below. Here you'll find the; 'Embed'...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found