Merge pull request from ttheuer/youtube-fix

Youtube fix, 2nd try
This commit is contained in:
Lorenz Hübschle-Schneider 2017-03-15 09:44:14 +01:00 committed by GitHub
commit 8bdefaa20b

View file

@ -209,18 +209,18 @@ plugins.factory('userPlugins', function() {
* See: https://developers.google.com/youtube/player_parameters * See: https://developers.google.com/youtube/player_parameters
*/ */
var youtubePlugin = new UrlPlugin('YouTube video', function(url) { var youtubePlugin = new UrlPlugin('YouTube video', function(url) {
var regex = /(?:youtube\.com|youtu\.be)\/(?:v\/|embed\/|watch(?:\?v=|\/))?([a-zA-Z0-9_-]+)/i, var regex = /(?:youtube\.com\/(?:[^\/]+\/.+\/|(?:v|e(?:mbed)?)\/|.*[?&]v=)|youtu\.be\/)([^"&?\/ ]{11})/i,
match = url.match(regex); match = url.match(regex);
if (match){ if (match){
var token = match[1], var token = match[1],
embedurl = "https://www.youtube.com/embed/" + token + "?html5=1&iv_load_policy=3&modestbranding=1&rel=0&showinfo=0", embedurl = "https://www.youtube.com/embed/" + token + "?html5=1&iv_load_policy=3&modestbranding=1&rel=0",
element = angular.element('<iframe></iframe>') element = angular.element('<iframe></iframe>')
.attr('src', embedurl) .attr('src', embedurl)
.attr('width', '560') .attr('width', '560')
.attr('height', '315') .attr('height', '315')
.attr('frameborder', '0') .attr('frameborder', '0')
.attr('allowfullscreen', 'true'); .attr('allowfullscreen', 'true');
return element.prop('outerHTML'); return element.prop('outerHTML');
} }
}); });