wordpress-seo
wordpress-seo copied to clipboard
Attachment page uses page URL for og:image URL
- [x] I've read and understood the contribution guidelines.
- [x] I've searched for any related issues and avoided creating a duplicate issue.
Please give us a description of what happened
To Reproduce
Step-by-step reproduction instructions
- Enable attachment pages
- Set featured image for post
Expected results
- og:image meta tag would use the URL of the actual image file
Actual results
- og:image uses URL of the current attachment page, essentially referring to itself as the image
Screenshots, screen recording, code snippet
Screenshot of source code: https://share.cleanshot.com/ZLGdvqk6
This is caused by this line of code which forces the current URL to be used if we are on an attachment page: https://github.com/Yoast/wordpress-seo/blob/18ee9e5960635309877f3b14eeb7a84cb84b9685/src/presenters/open-graph/image-presenter.php#L47C1-L50C5
Technical info
- If relevant, which editor is affected (or editors):
- [ ] Block Editor
- [ ] Gutenberg Editor
- [ ] Elementor Editor
- [ ] Classic Editor
- [ ] Other:
- Which browser is affected (or browsers):
- [x] Chrome
- [x] Firefox
- [x] Safari
- [x] Other:
Used versions
- Device you are using: any
- Operating system: any
- PHP version: any
- WordPress version:
- WordPress Theme:
- Yoast SEO version:
- Gutenberg plugin version:
- Elementor plugin version:
- Classic Editor plugin version:
- Relevant plugins in case of a bug: