Hi, so I’ve used the wix tutorial that teaches you how to collapse a video when there is no item data found. However the tutorial is only for video urls. Does anyone know how to hide an uploaded video/image? Here is my code:
$w.onReady(() => {
$w("#dataset3").onReady(() => {
// Gets the current item properties and stores them in a variable called item
const item = $w("#dataset3").getCurrentItem();
if (!item.video) {
// Checks if the current item has a value in the "video" field
// Collapses the video player if there is no value for "video"
$w("#videoPlayer1").collapse();
}
});
});
//========================= FOR VIDEO ↑ ========== FOR IMAGE ↓
$w.onReady(() => {
$w("#dataset3").onReady(() => {
// Gets the current item properties and stores them in a variable called item
const item = $w("#dataset3").getCurrentItem();
if (!item.video) {
// Checks if the current item has a value in the "video" field
// Collapses the video player if there is no value for "video"
$w("#image3").collapse();
}
});
});
My layout is this:
I have a repeater with a video & and an image on it. I want the video and/or image to collapse if no items can be found for them in the data collection.
I think I’m close, I just can’t seem to to find a work around.
You have an extra }) , unless this is the closure of the $w.onReady() that you haven’t posted.
Anyway it looks like the error you posted is not related to this code.
get the error
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://”.
The only work around I can think of is finding a way to upload a video through wix to a host server, then somehow retrieving that url and applying it to the wix database. I am not sure how to that though
Was there ever a follow up to this or did you get it working. I am in the same boat. I can get images to collapse no problem but not videos linked to a dataset.
I don’t know what console.log($w(“#videoplayer1”).src) print to the empty data coming from the collection, but try it yourself, for example if it’s print undefined or null or blabla . Write code like this.