'Conditionally hide a slide/div in image carousel based on whether the image source is present

I'm using WP All Import to import a number of images. For each item that gets imported, the number of images can vary so, I am importing a maximum of 100 images at a time. If the item doesn't have an image it creates this:

<div class="mySlides">
      <img src="" style="width: 100%; display: none;" onerror="this.style.display = "none"">
    </div>

When using the next/previous arrows of the image carousel, it triggers for the div to show, and no image is displayed, so I am left with a blank slide. I would prefer the slide not to show at all, and just rotate back through to the first slide that does contain an image.

Can someone help me determine the right script for this? Hopefully, I've explained it well enough... :/



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source