In some cases it might be neccessary to ignore image links if they contain a specific class attribute. Some themes or plugins generate a "related posts" section with a featured image where the image is added as linked image eventhough clicking it will open the post and not an image.
Also see here: https://wordpress.org/support/topic/lightbox-creates-gallery-of-all-images-on-page-not-just-in-the-gallery
In some cases it might be neccessary to ignore image links if they contain a specific class attribute. Some themes or plugins generate a "related posts" section with a featured image where the image is added as linked image eventhough clicking it will open the post and not an image.