rankmath / seo-by-rank-math

Rank Math is a revolutionary WordPress SEO Plugin that combines the features of many SEO tools and lets you multiply your traffic in the easiest way possible :bulb: :chart_with_upwards_trend: →
https://rankmath.com
107 stars 52 forks source link

Default `og:image` is not displayed #257

Closed Naaaaiix closed 11 months ago

Naaaaiix commented 11 months ago

Describe the bug When configuring a site I'm adding a fallback OpenGraph thumbnail on the 'SEO Title & Meta' section, but when I'm loading the page or post in concrete, what is displaying as a meta tag for og:image is the first image of the content.

Captura de pantalla 2023-10-30 a las 18 21 47

To Reproduce Steps to reproduce the behavior:

  1. Go to 'SEO Title & Meta'
  2. Add a fallback OpenGraph thumbnail
  3. Open a random page/post (not frontpage or archive/tag/category)
  4. Check the og:image meta tag

Expected behavior I'd expect to have what the text of the image is commenting: When a featured image or an OpenGraph Image is not set for individual posts/pages/CPTs, this image will be used as a fallback thumbnail when your post is shared on Facebook.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Additional context May I'm wrong, but seems the steps done to get the image doesn't fit with what the expected behavior commented. On requiring the images for any OpenGraph network the class Image is used, in concrete its method set_images:

https://github.com/rankmath/seo-by-rank-math/blob/5acf665a91ae87f2a64ead498e3fe6e773be33c2/includes/opengraph/class-image.php#L300-L334

The method set_singular_image() will be triggered on the switch, and here are the steps this methods is doing

https://github.com/rankmath/seo-by-rank-math/blob/5acf665a91ae87f2a64ead498e3fe6e773be33c2/includes/opengraph/class-image.php#L470-L502

So, basically:

  1. In case is a shop page, get that image (not the case)
  2. In case user has defined an image for that concrete post, use it.
  3. Get the image from the content

So, there's no trace of getting the image from the settings 👍

Naaaaiix commented 11 months ago

My fault; haven't seen this short-circuit 😝

https://github.com/rankmath/seo-by-rank-math/blob/5acf665a91ae87f2a64ead498e3fe6e773be33c2/includes/opengraph/class-image.php#L490