Connecting video from Database to Dynamic page

Hello, not sure how to connect a video on my database to my dynamic page.

Was easy for pictures. Manage field > field name > images > go to dynamic page > click add > select image > click my image uploads > done

for videos it’s manage video > field name > video > click add >. What next?

If if I go to videos none go to my collection.

And no stock videos as a stock video to change with “connect to data.”

Hi,
If you wish to display a video in a dynamic page you can use an HTML component. Change the website address to the URL of the video based on the path, check out this code for example:

import wixData from 'wix-data';
import wixLocation from 'wix-location';

$w.onReady(function () {
let path = wixLocation.path;// get the path  
wixData.query("videoTest")// find the relevant record in the database
  .eq("pageName",path)
  .find()
  .then( (results) => {
    let url = results.items[0].url; // get the url
    console.log(url);
    $w("#html1").src = url; // set the src to display the url
  } )
  .catch( (err) => {
    let errorMsg = err;
  } );

});

Good luck :slight_smile:

1 Like