Skip to content

Commit 484e09c

Browse files
author
Dmytro Voskoboinikov
committed
Merge branch 'MAGETWO-93270' into 2.3-bugfixes-150818
2 parents ac33680 + 16ca19a commit 484e09c

File tree

5 files changed

+51
-15
lines changed

5 files changed

+51
-15
lines changed

app/code/Magento/ProductVideo/view/adminhtml/web/js/get-video-information.js

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ define([
8686
this._height = this.element.data('height');
8787
this._autoplay = !!this.element.data('autoplay');
8888
this._playing = this._autoplay || false;
89+
this.useYoutubeNocookie = this.element.data('youtubenocookie') || false;
8990

9091
this._responsive = this.element.data('responsive') !== false;
9192

@@ -163,6 +164,12 @@ define([
163164
* @private
164165
*/
165166
'youtubeapiready': function () {
167+
var host = 'https://www.youtube.com';
168+
169+
if (self.useYoutubeNocookie) {
170+
host = 'https://www.youtube-nocookie.com';
171+
}
172+
166173
if (self._player !== undefined) {
167174
return;
168175
}
@@ -177,6 +184,7 @@ define([
177184
width: self._width,
178185
videoId: self._code,
179186
playerVars: self._params,
187+
host: host,
180188
events: {
181189

182190
/**
@@ -469,7 +477,8 @@ define([
469477
description: tmp.snippet.description,
470478
thumbnail: tmp.snippet.thumbnails.high.url,
471479
videoId: videoInfo.id,
472-
videoProvider: videoInfo.type
480+
videoProvider: videoInfo.type,
481+
useYoutubeNocookie: videoInfo.useYoutubeNocookie
473482
};
474483
this._videoInformation = respData;
475484
this.element.trigger(this._UPDATE_VIDEO_INFORMATION_TRIGGER, respData);
@@ -600,7 +609,8 @@ define([
600609
var id,
601610
type,
602611
ampersandPosition,
603-
vimeoRegex;
612+
vimeoRegex,
613+
useYoutubeNocookie = false;
604614

605615
if (typeof href !== 'string') {
606616
return href;
@@ -620,9 +630,13 @@ define([
620630
id = id.substring(0, ampersandPosition);
621631
}
622632

623-
} else if (href.host.match(/youtube\.com|youtu\.be/)) {
633+
} else if (href.host.match(/youtube\.com|youtu\.be|youtube-nocookie.com/)) {
624634
id = href.pathname.replace(/^\/(embed\/|v\/)?/, '').replace(/\/.*/, '');
625635
type = 'youtube';
636+
637+
if (href.host.match(/youtube-nocookie.com/)) {
638+
useYoutubeNocookie = true;
639+
}
626640
} else if (href.host.match(/vimeo\.com/)) {
627641
type = 'vimeo';
628642
vimeoRegex = new RegExp(['https?:\\/\\/(?:www\\.|player\\.)?vimeo.com\\/(?:channels\\/(?:\\w+\\/)',
@@ -640,7 +654,7 @@ define([
640654
}
641655

642656
return id ? {
643-
id: id, type: type, s: href.search.replace(/^\?/, '')
657+
id: id, type: type, s: href.search.replace(/^\?/, ''), useYoutubeNocookie: useYoutubeNocookie
644658
} : false;
645659
}
646660
});

app/code/Magento/ProductVideo/view/adminhtml/web/js/new-video-dialog.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ define([
2121
container: '.video-player-container',
2222
videoClass: 'product-video',
2323
reset: false,
24+
useYoutubeNocookie: false,
2425
metaData: {
2526
DOM: {
2627
title: '.video-information.title span',
@@ -87,13 +88,17 @@ define([
8788
*/
8889
_doUpdate: function () {
8990
this.reset();
90-
this.element.find(this.options.container).append('<div class="' +
91-
this.options.videoClass +
92-
'" data-type="' +
93-
this.options.videoProvider +
94-
'" data-code="' +
95-
this.options.videoId +
96-
'" data-width="100%" data-height="100%"></div>');
91+
this.element.find(this.options.container).append(
92+
'<div class="' +
93+
this.options.videoClass +
94+
'" data-type="' +
95+
this.options.videoProvider +
96+
'" data-code="' +
97+
this.options.videoId +
98+
'" data-youtubenocookie="' +
99+
this.options.useYoutubeNocookie +
100+
'" data-width="100%" data-height="100%"></div>'
101+
);
97102
this.element.find(this.options.metaData.DOM.wrapper).show();
98103
this.element.find(this.options.metaData.DOM.title).text(this.options.metaData.data.title);
99104
this.element.find(this.options.metaData.DOM.uploaded).text(this.options.metaData.data.uploaded);
@@ -337,6 +342,7 @@ define([
337342
.createVideoPlayer({
338343
videoId: data.videoId,
339344
videoProvider: data.videoProvider,
345+
useYoutubeNocookie: data.useYoutubeNocookie,
340346
reset: false,
341347
metaData: {
342348
DOM: {

app/code/Magento/ProductVideo/view/frontend/web/js/fotorama-add-video-events.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ define([
3434
var id,
3535
type,
3636
ampersandPosition,
37-
vimeoRegex;
37+
vimeoRegex,
38+
useYoutubeNocookie = false;
3839

3940
/**
4041
* Get youtube ID
@@ -68,9 +69,13 @@ define([
6869
id = _getYoutubeId(id);
6970
type = 'youtube';
7071
}
71-
} else if (href.host.match(/youtube\.com|youtu\.be/)) {
72+
} else if (href.host.match(/youtube\.com|youtu\.be|youtube-nocookie.com/)) {
7273
id = href.pathname.replace(/^\/(embed\/|v\/)?/, '').replace(/\/.*/, '');
7374
type = 'youtube';
75+
76+
if (href.host.match(/youtube-nocookie.com/)) {
77+
useYoutubeNocookie = true;
78+
}
7479
} else if (href.host.match(/vimeo\.com/)) {
7580
type = 'vimeo';
7681
vimeoRegex = new RegExp(['https?:\\/\\/(?:www\\.|player\\.)?vimeo.com\\/(?:channels\\/(?:\\w+\\/)',
@@ -85,7 +90,7 @@ define([
8590
}
8691

8792
return id ? {
88-
id: id, type: type, s: href.search.replace(/^\?/, '')
93+
id: id, type: type, s: href.search.replace(/^\?/, ''), useYoutubeNocookie: useYoutubeNocookie
8994
} : false;
9095
}
9196

@@ -281,6 +286,7 @@ define([
281286
tmpVideoData.id = dataUrl.id;
282287
tmpVideoData.provider = dataUrl.type;
283288
tmpVideoData.videoUrl = tmpInputData.videoUrl;
289+
tmpVideoData.useYoutubeNocookie = dataUrl.useYoutubeNocookie;
284290
}
285291

286292
videoData.push(tmpVideoData);
@@ -629,6 +635,8 @@ define([
629635
videoData.provider +
630636
'" data-code="' +
631637
videoData.id +
638+
'" data-youtubenocookie="' +
639+
videoData.useYoutubeNocookie +
632640
'" data-width="100%" data-height="100%"></div>'
633641
);
634642
},

app/code/Magento/ProductVideo/view/frontend/web/js/load-player.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ define(['jquery', 'jquery/ui'], function ($) {
8888
this._playing = this._autoplay || false;
8989
this._loop = this.element.data('loop');
9090
this._rel = this.element.data('related');
91+
this.useYoutubeNocookie = this.element.data('youtubenocookie') || false;
9192

9293
this._responsive = this.element.data('responsive') !== false;
9394

@@ -164,6 +165,12 @@ define(['jquery', 'jquery/ui'], function ($) {
164165
* Handle event
165166
*/
166167
'youtubeapiready': function () {
168+
var host = 'https://www.youtube.com';
169+
170+
if (self.useYoutubeNocookie) {
171+
host = 'https://www.youtube-nocookie.com';
172+
}
173+
167174
if (self._player !== undefined) {
168175
return;
169176
}
@@ -182,6 +189,7 @@ define(['jquery', 'jquery/ui'], function ($) {
182189
width: self._width,
183190
videoId: self._code,
184191
playerVars: self._params,
192+
host: host,
185193
events: {
186194

187195
/**

lib/web/fotorama/fotorama.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,7 @@ fotoramaVersion = '4.6.4';
831831
}
832832
type = 'youtube';
833833
}
834-
} else if (href.host.match(/youtube\.com|youtu\.be/)) {
834+
} else if (href.host.match(/youtube\.com|youtu\.be|youtube-nocookie.com/)) {
835835
id = href.pathname.replace(/^\/(embed\/|v\/)?/, '').replace(/\/.*/, '');
836836
type = 'youtube';
837837
} else if (href.host.match(/vimeo\.com/)) {

0 commit comments

Comments
 (0)