Skip to content

Commit 5f60b41

Browse files
committed
[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: as is existing behaviour See this fix in action at by clicking the vimeo videos on the right. https://www.listcorp.com/asx/ler
1 parent 4cc502e commit 5f60b41

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

js/jquery.prettyPhoto.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,8 @@
279279
movie_id = movie_id.substr(0,movie_id.indexOf('&')); // Strip anything after the &
280280
}
281281

282-
movie = 'http://www.youtube.com/embed/'+movie_id;
282+
var protocol = document.location.protocol.startsWith('http') ? document.location.protocol : 'http:';
283+
movie = protocol+'//www.youtube.com/embed/'+movie_id;
283284
(getParam('rel',pp_images[set_position])) ? movie+="?rel="+getParam('rel',pp_images[set_position]) : movie+="?rel=1";
284285

285286
if(settings.autoplay) movie += "&autoplay=1";
@@ -293,8 +294,9 @@
293294
movie_id = pp_images[set_position];
294295
var regExp = /http(s?):\/\/(www\.)?vimeo.com\/(\d+)/;
295296
var match = movie_id.match(regExp);
296-
297-
movie = 'http://player.vimeo.com/video/'+ match[3] +'?title=0&byline=0&portrait=0';
297+
298+
var protocol = document.location.protocol.startsWith('http') ? document.location.protocol : 'http:';
299+
movie = protocol+'//player.vimeo.com/video/'+ match[3] +'?title=0&byline=0&portrait=0';
298300
if(settings.autoplay) movie += "&autoplay=1;";
299301

300302
vimeo_width = pp_dimensions['width'] + '/embed/?moog_width='+ pp_dimensions['width'];

0 commit comments

Comments
 (0)