From e708d6706a65fe4632e35197a9bdf7d669a089ea Mon Sep 17 00:00:00 2001 From: darylteo Date: Thu, 15 Oct 2015 14:33:28 +1100 Subject: [PATCH] [FIX] #156 Browser complains about mixed content If a site is loaded using https:// youtube videos (and probably other embeds) will not load because the script hard codes http in the video URLs The following fix is as follows: - only applies to video urls (any impact on other embeds unknown) - checks for the current document protocol (http: or https:) - if protocol is file:, then it defaults to - http for youtube as it is existing behaviour - specified protocol in the vimeo url (new behaviour) See this fix in action at by clicking the vimeo videos on the right. https://www.listcorp.com/asx/ler --- js/jquery.prettyPhoto.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/js/jquery.prettyPhoto.js b/js/jquery.prettyPhoto.js index 9ecf9d1..3ce6c65 100644 --- a/js/jquery.prettyPhoto.js +++ b/js/jquery.prettyPhoto.js @@ -279,7 +279,8 @@ movie_id = movie_id.substr(0,movie_id.indexOf('&')); // Strip anything after the & } - movie = 'http://www.youtube.com/embed/'+movie_id; + var protocol = document.location.protocol.startsWith('http') ? document.location.protocol : 'http:'; + movie = protocol+'//www.youtube.com/embed/'+movie_id; (getParam('rel',pp_images[set_position])) ? movie+="?rel="+getParam('rel',pp_images[set_position]) : movie+="?rel=1"; if(settings.autoplay) movie += "&autoplay=1"; @@ -293,8 +294,9 @@ movie_id = pp_images[set_position]; var regExp = /http(s?):\/\/(www\.)?vimeo.com\/(\d+)/; var match = movie_id.match(regExp); - - movie = 'http://player.vimeo.com/video/'+ match[3] +'?title=0&byline=0&portrait=0'; + + var protocol = document.location.protocol.startsWith('http') ? document.location.protocol : match[1]+':'; + movie = protocol+'//player.vimeo.com/video/'+ match[3] +'?title=0&byline=0&portrait=0'; if(settings.autoplay) movie += "&autoplay=1;"; vimeo_width = pp_dimensions['width'] + '/embed/?moog_width='+ pp_dimensions['width'];