Last month Yoast added a feature to their Yoast SEO (aka WordPress SEO) plugin to allow redirecting attachment pages to the media itself (image, video, PDF, etc). For example, an attachment page with an image would be redirected to the full size image. The reason given by Yoast is that attachment pages are simply an HTML wrapper around an image, and provide little to no value for SEO.
This may be true IF the attachment page does not include any Schema markup — either as JSON-LD or microdata — to provide Google (Bing and Pinterest too) with information about the media, AND you’ve not entered a title, caption, alternative text, and description for your media in the WordPress Media library (if you haven’t, you really should).
And if you’re using the WPSSO Core plugin with its WPSSO Schema JSON-LD Markup add-on, for example, you probably would NOT want to redirect attachment pages to the media file — you’ll just be throwing away all that awesome SEO markup about the media. ;-)
What about sharing attachment page URLs vs image URLs?
Whether your attachment page has Schema markup or not, one thing is certain — if you want to share an image on social sites, you should share the attachment page URL, not the media file URL (image, video, PDF, etc).
For example, a shared JPEG image URL does NOT bring potential customers back to your site — it’s just an image. A shared image URL is shown on social sites as an image — without a link back to a page on your site, without a title, and without a description. You can enter additional text in the social post itself, but that text is easily lost when the shared is re-shared — you’re much better off sharing an attachment page URL, which will link back to your site. ;-)
For example, let’s compare sharing an attachment page URL and an image URL on Facebook:
As you can see, the shared attachment page URL contains more information, and links back to the attachment page — definitely a better option than sharing a simple image URL.