Skip to content

Commit

Permalink
Cleaner URLs by avoiding setting default options
Browse files Browse the repository at this point in the history
  • Loading branch information
mmtr committed Aug 2, 2019
1 parent ac48fe8 commit 765e372
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions extensions/blocks/videopress/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,20 @@ export const getVideoPressUrl = ( guid, { autoplay, controls, loop, muted, poste
return null;
}

// In order to have a cleaner URL, we only set the options differing from the default VideoPress player settings:
// - Autoplay: Turned off by default.
// - Controls: Turned on by default.
// - Loop: Turned off by default.
// - Muted: Turned off by default.
// - Poster: No image by default.
// - Preload: None by default.
const options = {
autoPlay: autoplay,
controls,
loop,
muted,
...( muted && { persistVolume: false } ),
posterUrl: poster,
preload,
...( autoplay && { autoPlay: true } ),
...( ! controls && { controls: false } ),
...( loop && { loop: true } ),
...( muted && { muted: true, persistVolume: false } ),
...( poster && { posterUrl: poster } ),
...( preload !== 'none' && { preloadContent: preload } ),
};
return addQueryArgs( `https://videopress.com/v/${ guid }`, options );
};

0 comments on commit 765e372

Please sign in to comment.