Skip to content

Commit

Permalink
New: Add option to use the no cookie domain from youtube (default to …
Browse files Browse the repository at this point in the history
…true)
  • Loading branch information
jonnitto committed Jul 9, 2024
1 parent 0672463 commit 382b2b3
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 4 deletions.
3 changes: 3 additions & 0 deletions Configuration/Settings.Jonnitto.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ Jonnitto:
fallbackAspectRatio: '16 / 9'

YouTube:
# Use the no cookie domain (https://www.youtube-nocookie.com) for youtube
useYoutubeNoCookieDomain: true

# Set to false to disable the gdpr message, set to popup open the video in a new window or set to true to show the message in the player
gdprHandling: true

Expand Down
6 changes: 5 additions & 1 deletion Resources/Private/Assets/Plugins/YouTube.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default function (Alpine) {

function handeleRoot({ element, Alpine, options }) {
const type = 'YouTube';
let { video, playlist, style, slim, loop } = options;
let { video, playlist, style, slim, loop, noCookie } = options;

const videoPlayerOptions = {
playerVars: {
Expand All @@ -27,6 +27,10 @@ function handeleRoot({ element, Alpine, options }) {
},
};

if (noCookie) {
videoPlayerOptions.host = 'https://www.youtube-nocookie.com';
}

if (video) {
videoPlayerOptions.videoId = video;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ prototype(Jonnitto.PrettyEmbed:Presentation.Iframe) < prototype(Neos.Fusion:Comp
aspectRatio = ${PropTypes.anyOf(PropTypes.string, PropTypes.float, PropTypes.integer)}
setAspectRatioClass = ${PropTypes.boolean}
preserveAspectRatio = ${PropTypes.boolean}
useYoutubeNoCookieDomain = ${PropTypes.boolean}
fallbackAspectRatio = ${PropTypes.anyOf(PropTypes.string, PropTypes.float, PropTypes.integer)}
controls = ${PropTypes.boolean}
lightbox = ${PropTypes.boolean}
Expand Down Expand Up @@ -80,7 +81,8 @@ prototype(Jonnitto.PrettyEmbed:Presentation.Iframe) < prototype(Neos.Fusion:Comp
playlist: props.playlistID || null,
slim: !props.controls || null,
style: props.lightbox && 'lightbox' || null,
loop: props.loop || null
loop: props.loop || null,
noCookie: props.useYoutubeNoCookieDomain || null
})}
x-prettyembedyoutube.@if={props.player== 'YouTube' && !props._alwaysOpenInPopup}
aria-label={props.label}
Expand Down
1 change: 1 addition & 0 deletions Resources/Private/Fusion/Presentation/YouTube.fusion
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ prototype(Jonnitto.PrettyEmbed:Presentation.YouTube) < prototype(Jonnitto.Pretty
lightbox = ${Configuration.setting('Jonnitto.PrettyEmbed.YouTube.lightbox')}
preserveAspectRatio = ${Configuration.setting('Jonnitto.PrettyEmbed.YouTube.preserveAspectRatio')}
fallbackAspectRatio = ${Configuration.setting('Jonnitto.PrettyEmbed.YouTube.fallbackAspectRatio')}
useYoutubeNoCookieDomain = ${Configuration.setting('Jonnitto.PrettyEmbed.YouTube.useYoutubeNoCookieDomain')}
}
2 changes: 1 addition & 1 deletion Resources/Public/Modules/YouTube.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 382b2b3

Please sign in to comment.