wordpress-seo icon indicating copy to clipboard operation
wordpress-seo copied to clipboard

Attachment page uses page URL for og:image URL

Open derekashauer opened this issue 2 years ago • 0 comments

  • [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

  1. Enable attachment pages
  2. Set featured image for post

Expected results

  1. og:image meta tag would use the URL of the actual image file

Actual results

  1. 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:

derekashauer avatar Oct 23 '24 18:10 derekashauer