Skip to content

Commit

Permalink
[FIX] scaron#156 Browser complains about mixed content
Browse files Browse the repository at this point in the history
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: as is
   existing behaviour

See this fix in action at by clicking the vimeo videos on the
right.

https://www.listcorp.com/asx/ler
  • Loading branch information
darylteo committed Oct 15, 2015
1 parent 4cc502e commit 5f60b41
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions js/jquery.prettyPhoto.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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 : 'http:';
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'];
Expand Down

0 comments on commit 5f60b41

Please sign in to comment.