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.
Thanks in advance.
I have tried every bit of code I can find and none seem to work as it is based on URL video, not video added to the collection by uploading it.
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.
if($w("#videoplayer1").src===blabla){ $w("#videoplayer1").collapse() }else{ $w("#videoplayer1").expand() }
As I show in the picture below.
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.
$w.onReady(function () { $w("#dataset1").onReady(() => { const item = $w("#dataset1").getCurrentItem(); const [video, image1, image2, image3, image4, image5] = [item.video, item.image1, item.image2, item.image3, item.image4, item.image5]; if (!item.video) { $w("#videoPlayer1").collapse(); } else if (!item.image1) { $w("#image1").collapse(); } else if (!item.image2) { $w("#image2").collapse(); } else if (!item.image3) { $w("#image3").collapse(); } else if (!item.image4) { $w("#image4").collapse(); } else if (!item.image5) { $w("#image5").collapse(); } else { $w("#videoPlayer1").expand(); $w("#image1").expand(); $w("#image2").expand(); $w("#image3").expand(); $w("#image4").expand(); $w("#image5").expand(); } }); });
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 message of the error speaks about the smallness of the felid
Could you write the correct formula
Please
Thanks
$w("#dataset1").onReady(() => { const item =
$w("#dataset1").getCurrentItem(); if (!item.video) { $w("#videoPlayer1").collapse(); } }); });
The code work with URL FIELD types
But video field types not work
Get error messages
I have the same problem 😕
Please guys how has idea to