Connecting Lightbox elements to data

I’m trying to set up a promotional homepage lightbox that my clients can easily change the content of by connecting it to a dataset. For some reason, my connected video is not loading on the site.

The thing is, I want them to be able to choose whether the popup displays a photo or a video, since this is for their seasonal promotions. So I’ve written some code to show or hide the photo, but none of it is working (except the image staying hidden).

Here’s my code:

$w.onReady(function () {
    $w("#videoPlayer1").play();
});
 

 if ( $w("#videoPlayer1").isPlaying ) {
        $w("#image11").hide();
    }

 else { ( $w("#image11").show() );

    }

Here’s what my lightbox looks like:

All help is greatly appreciated!

  1. All the if-else should be inside the $w.onReady

  2. Some browsers block video playing if it’s not initiated by manual click.

  • remove the characters in red:
 else { ( $w("#image11").show() );

Thanks for the help! I was wondering if you had any advice on making so that if my client uploads a video, it will show up in the lightbox, but if they upload a photo, that will show up instead?

I got this error when connecting the data table:

Wix code SDK error: The "src" property cannot be set to "". It must be a valid image URL starting with "http://", "https://" or "wix:image://", or a valid video URL starting with "wix:video://".

Thanks in advance!

Nobody has any ideas?