length of a gallery

Just do something simple like this.

  
$w.onReady(() => {
$w("#myDataset").onReady(() => {
// Gets the current item properties and stores them in a variable called item
const item = $w("#myDataset").getCurrentItem();
// Checks if the current item has a value in the "picture" field
if (!item.picture) {
// Collapses the gallery if there is no value for "picture"
$w("#gallery").collapse();
}
});
});