I'm attempting to trick a Pro Gallery called #gallery2 into collapsing when a 1x1 pixel image titled "Blank" is set as a gallery image.
I have a dynamic page, but not every project has an image, so I want the large space where the gallery is to collapse.
import wixData from 'wix-data'; $w.onReady(function(){ $w("#dynamicDataset").onReady(() => { console.log("check") imageMngr(); }); }); function imageMngr() { $w("#gallery2").currentItem if ($w("#gallery2").currentItem.title !== "Blank") { $w("#gallery2").collapse() } else{$w("#gallery2").expand()} }
This is an old post, i know, but just came across this as i was googling for this same problem, you legends! thanks for having this community!
Hey! I have basically the same thing setup on my site. I have my gallery in a strip, and when there are no images in the gallery database field I have the strip collapse with the following code.
You could remove the "blank" image and just leave the field empty and this should work.
import wixData from 'wix-data'; $w.onReady(function () { $w("#dynamicDataset").onReady(() => { var item = $w("#dynamicDataset").getCurrentItem(); if (item["your field title"] === undefined) $w("#extensionStrip").collapse(); else $w("#extensionStrip").expand(); }); });