Skip to content

Commit 5578b5b

Browse files
author
Dmytro Voskoboinikov
committed
Merge branch 'MAGETWO-93272' into 2.2.6-bugfixes-250718
2 parents 100e81a + 3dbc149 commit 5578b5b

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',
@@ -90,13 +91,17 @@ define([
9091
uploaderLink;
9192

9293
this.reset();
93-
this.element.find(this.options.container).append('<div class="' +
94-
this.options.videoClass +
95-
'" data-type="' +
96-
this.options.videoProvider +
97-
'" data-code="' +
98-
this.options.videoId +
99-
'" data-width="100%" data-height="100%"></div>');
94+
this.element.find(this.options.container).append(
95+
'<div class="' +
96+
this.options.videoClass +
97+
'" data-type="' +
98+
this.options.videoProvider +
99+
'" data-code="' +
100+
this.options.videoId +
101+
'" data-youtubenocookie="' +
102+
this.options.useYoutubeNocookie +
103+
'" data-width="100%" data-height="100%"></div>'
104+
);
100105
this.element.find(this.options.metaData.DOM.wrapper).show();
101106
this.element.find(this.options.metaData.DOM.title).text(this.options.metaData.data.title);
102107
this.element.find(this.options.metaData.DOM.uploaded).text(this.options.metaData.data.uploaded);
@@ -335,6 +340,7 @@ define([
335340
.createVideoPlayer({
336341
videoId: data.videoId,
337342
videoProvider: data.videoProvider,
343+
useYoutubeNocookie: data.useYoutubeNocookie,
338344
reset: false,
339345
metaData: {
340346
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

@@ -283,6 +288,7 @@ define([
283288
tmpVideoData.id = dataUrl.id;
284289
tmpVideoData.provider = dataUrl.type;
285290
tmpVideoData.videoUrl = tmpInputData.videoUrl;
291+
tmpVideoData.useYoutubeNocookie = dataUrl.useYoutubeNocookie;
286292
}
287293

288294
videoData.push(tmpVideoData);
@@ -631,6 +637,8 @@ define([
631637
videoData.provider +
632638
'" data-code="' +
633639
videoData.id +
640+
'" data-youtubenocookie="' +
641+
videoData.useYoutubeNocookie +
634642
'" data-width="100%" data-height="100%"></div>'
635643
);
636644
},

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)