I recently noticed that some of the images on my Wordpress website are the pages with the most visits according to Google Analytics. The images could be accessed by clicking them. The result was the pages being opened in a separate tab (no lightbox etc.). I now deactivated this so now one has to right-click and say "open image in new tab" to get the same results as before. Still I'd like to know how this happens and how I can redirect someone who is accessing the direct image path to the page where the image in on?
I noticed YoastSEO is adressing this issue here: https://kb.yoast.com/kb/redirect-image-attachment-urls/ But it does not work for me.