dimsemenov/Magnific-Popup

Youtube link does not load using t parameter in url

samdenis516 opened this issue · 4 comments

I am getting a "youtube refused to connect" when i add the t paremeter to my youtube url. ex Open YouTube video

pirco commented

+1

the problem is that the parameter ?t=XX should be "translated" into ?start=XX

Hi, has this issue been resolved?
above fix, by changing ?t=XX to ?start=XX is not working

Running into the same issue, especially as described in #1162:

ie. https://www.youtube.com/watch?v=MEDXwwDeP5o works
but https://www.youtube.com/watch?v=MEDXwwDeP5o&t=293s does not

This is caused by the way how magnificPopup extracts the YouTube ID from the URL, as it uses the rest of the string after v=:

embedSrc = embedSrc.substr(embedSrc.lastIndexOf(this.id)+this.id.length, embedSrc.length);

So, https://www.youtube.com/watch?v=MEDXwwDeP5o&t=293s gets converted to //www.youtube.com/embed/MEDXwwDeP5o&t=293s?autoplay=1, the ? for URL query arguments is placed wrong.

In #213 (comment) a solution through regular expression was already suggested, which would solve the issue.