Streaming live at 10am (PST)

Jquery help to remove empty thumbnails


I have an issue whereby I’m populating a lightbox using a cms list and it works fine. However, if some cms fields aren’t populated, a blank thumbnail appears in the lightbox thumbnail list at the bottom of the screen. I’ve made a jsfiddle out of it and I’m looking to find a solution that removes lightbox thumbnail which are empty.

Open the JsFiddle and Run. Then click “more photos from the event” to see what I’m talking about

Any help would be greatly appreciated!

Thanks in advance


Please check PM,


Hi @Diarmuid_Sexton,

Could conditional visibility help you there ?
Not sure if that is what you’re looking for though.

Hi @anthonysalamin,

Thanks for taking the time to answer but no - it won’t work in this situation as what I’m using is custom code.

However, I found the jquery


1 Like

Well that’s really interesting indeed, thank you for sharing that bit of code !

Hey Man,

thanks for your code! However if I implement it into the embed html,
the Lightbox won’t open anymore. Do you have an idea?

Thanks in advance!

Hi @Diarmuid_Sexton , your piece of code works great in the chrome console but I can’t seem to make it work in my webflow project… I use the lightbox CMS workaround + conditionnal visibility on lightbox links.

Is there something to declare first ? Like to opening of the lightbox for instance ?
I tried adding document ready or window onload but apparently it runs to early…
Where did you inject this snippet for it to work ?

Thanks for sharing the jquery solution anyway :slight_smile:

Hi @pepperclip,

I haven’t done anything special. Be sure to place it in the footer - of either the page or of the entire site - as it uses Jquery and jquery is only loaded at the start of the footer.

Thanks for answering so quickly !

Unfortunately it doesn’t work (either in page custom code or site wide custom code.)

I’ve tried inserting it after the custom code for CMS lightbox in embed and doesn’t work either…
I think I’m missing some simple thing and can’t figure out what…

In the chrome inspector console,
only works when triggered with the lightbox opened. If you trigger it before opening it doesn’t remove the lightbox item like required…

Sorry, I’m sure either. Put it into jsfiddle and play around with it.

Hmm… Ok, thanks anyway.
Since I’ve been trying stuff with no success for a couple of hours, I’m going for a dirty CSS workaround for now which I’ll share for those who might have the same issue as me :slight_smile:

You can just add this

 .w-lightbox-thumbnail {
    .w-lightbox-spinner {

In order to hide the “empty” item and have the spinner be hidden under the other images.

It doesn’t solve the real problem (which is to hide from CMS lightbox empty items) but it hides it from the user…


For future reference, this works to remove empty thumbnails by removing the lightbox link in the main page if the image src is empty.


      if ($(this).find(".lightbox-image").attr("src") === "")         
1 Like

Hi @Diarmuid_Sexton

I could not get your jquery to work…Have you cracked it since your last post? I would be majorly keen to hear about any developments, I see you have tried and suggested a few variations of code snippets. My Js skills are non-existent so I am no help to you unfortunately and have settled for @pepperclip 's handy bit of CSS for now.

You can maybe try something even more straightforward like :


This removes all elements of a specific class which don’t have a specified image source (therefore should clean up empty thumbnails)

Hi @pepperclip this just does not work for me, unfortunately. I probably have set up the lightbox pretty strangely…

I do not have an image src in the html emded code, just an empty link over background images which activates the lightbox. Perhaps this is the reason why I am struggling to locate a specific class to target for this js code snippet.

I have inputted 4 classes hoping 1 would work…

$(".w-inline-block .w-lightbox .link-block-lightbox .html-embed-lightbox:has(img[src=''])").remove();

Thanks for your help thus far…I may just have to hide the thumbnails altogether…