Replacing all attachment links in post with media file link
I’m working on a WordPress site, where all images inside posts are linking to the corresponding attachment pages. I want to use a lightbox but obviously this would require changing all the links back to the media files directly (e.g. xyz.jpg).
The site has a significant number of posts and images so it would be impossible to do this manually.
Does anyone know of solution that would simply replace – in bulk – all of the image links to link to the media file, instead of the attachment page?