11/* eslint n/no-unsupported-features/node-builtins: "off" */
22/* globals photoBooth photoboothTools */
3+
4+ function addCacheBustingParam ( ) {
5+ const url = getBasePreviewUrl ( ) ;
6+ const timestamp = new Date ( ) . getTime ( ) ;
7+
8+ if ( url . includes ( '?' ) ) {
9+ return `${ url } &t=${ timestamp } ` ;
10+ }
11+
12+ return `${ url } ?t=${ timestamp } ` ;
13+ }
14+
15+ function getBasePreviewUrl ( ) {
16+ if ( ! config . preview || ! config . preview . url ) {
17+ return '' ;
18+ }
19+
20+ const raw = config . preview . url ;
21+ const match = raw . match ( / ^ u r l \( ( [ ' " ] ? ) ( .+ ?) \1\) $ / ) ;
22+
23+ return match ? match [ 2 ] : raw ;
24+ }
25+
326const photoboothPreview = ( function ( ) {
427 // vars
528 const CameraDisplayMode = {
@@ -163,6 +186,7 @@ const photoboothPreview = (function () {
163186 } else if ( config . preview . mode === PreviewMode . URL . valueOf ( ) ) {
164187 photoboothTools . console . logDev ( 'Preview: Preview at countdown from URL.' ) ;
165188 setTimeout ( function ( ) {
189+ url . css ( 'background-image' , 'url("' + addCacheBustingParam ( ) + '")' ) ;
166190 url . show ( ) ;
167191 url . addClass ( 'streaming' ) ;
168192 } , config . preview . url_delay ) ;
@@ -175,6 +199,7 @@ const photoboothPreview = (function () {
175199 } else if ( config . preview . mode === PreviewMode . URL . valueOf ( ) ) {
176200 photoboothTools . console . logDev ( 'Preview: Preview from URL.' ) ;
177201 setTimeout ( function ( ) {
202+ url . css ( 'background-image' , 'url("' + addCacheBustingParam ( ) + '")' ) ;
178203 url . show ( ) ;
179204 url . addClass ( 'streaming' ) ;
180205 } , config . preview . url_delay ) ;
@@ -203,6 +228,7 @@ const photoboothPreview = (function () {
203228 }
204229 url . removeClass ( 'streaming' ) ;
205230 url . hide ( ) ;
231+ url . css ( 'background-image' , 'none' ) ;
206232 video . hide ( ) ;
207233 pictureFrame . hide ( ) ;
208234 collageFrame . hide ( ) ;
0 commit comments