Yoast / wordpress-seo

Yoast SEO for WordPress
https://yoast.com/wordpress/plugins/seo/
Other
1.75k stars 885 forks source link

Issues with custom FB image sizes & og:image tags #10863

Closed jonoalderson closed 1 year ago

jonoalderson commented 6 years ago

This is a cleaned up version of https://github.com/Yoast/wordpress-seo/issues/9699 Issue as described by @mahnunchik.


Summary

When using setting a custom image size via wpseo_opengraph_image_size, some scenarios result in the og:image tag not being output.

Specifically, we've identified the following scenario:

My suspicion is that one of two things are happening:

  1. We simply has a 'greater than' condition somewhere, rather than a 'greater than or equal to' condition when validating the og:image range/contents.
  2. The code we're using to determine appropriate image ratios has a similar bug.

Image size registration code sample

// functions.php
    add_image_size( 'twentyseventeen-featured-image', 2000, 1200, true );

// add according http://hookr.io/filters/wpseo_opengraph_image_size/

add_filter( 'wpseo_opengraph_image_size', 'opengraph_image_size', 10, 1 );

function opengraph_image_size( $string ) {
    return 'twentyseventeen-featured-image';
}

Walkthrough

  1. Register the custom image size.

  2. Create a post, and use the following featured image (which is 3782 x 2418). This works correctly. 3782x2418

  3. Create a second post, and use the following image (which is 2000 x 1200). The og:image tags are incorrectly omitted. 2000x1200

mahnunchik commented 6 years ago

😭

mahnunchik commented 5 years ago

It is not funny! I could not update this plugin since May!

mahnunchik commented 5 years ago

@jono-alderson @IreneStr @jdevalk @benvaassen @atimmer Why you ignore broken og:image feature?

jonoalderson commented 5 years ago

Hey @mahnunchik,

Sorry you're still having problems with this. We've made a bunch of improvements to how our open graph logic works recently, and I'd hoped we'd caught this. It's still on our list to evaluate, and we'll get to it as soon as we can prioritise it :)

mahnunchik commented 5 years ago

Sounds good

bishless commented 5 years ago

I came here to report this problem and ran across this issue while searching. It feels pretty silly to have Yoast give me a recommended image size: 1600x630, suggest a way to leverage custom image sizes in WP, and then completely ignore that image when I upload an image at that size for opengraph ALL WHILE outputting the expected, manually set Twitter image.

/facepalm

I bumped an image up to 1680x672, uploaded it, and now the 1600x630 version is output in the open graph metadata rather than our 'default' opengraph image.

Victory... but only after not following the recommendation.

mahnunchik commented 5 years ago

@jono-alderson any news since May?

guidodipaolo commented 5 years ago

@jono-alderson I have updated Yoast to 9.2.1 version. Suddenly in many post of my blog the og:image meta disapears. Why is happening this ? There is a dimension limitation ? There is a file weight limitation ?

moorscode commented 5 years ago

Hi @guidodipaolo

You mention that you have updated to 9.2.1, but you did not specify from which version you were upgrading.

Since 9.0 we have changed the way we dynamically retrieve images from the content. This was giving a lot of performance problems.

Related https://github.com/Yoast/wordpress-seo/issues/11345, https://github.com/Yoast/wordpress-seo/issues/11262

jdevalk commented 5 years ago

@jono-alderson can you revisit this and see if it's still in need of fixing?

mahnunchik commented 5 years ago

I'm still waiting!

jonoalderson commented 5 years ago

I can confirm this is still an issue. Re-tested on 11.6.

mahnunchik commented 5 years ago

Original issue was created on 11 May 2018 https://github.com/Yoast/wordpress-seo/issues/9699

I'm moving to another plugin.

What do you think? Which of these plugins is better?

  1. The SEO Framework https://wordpress.org/plugins/autodescription/
  2. WordPress SEO Plugin — Rank Math https://wordpress.org/plugins/seo-by-rank-math/
jonoalderson commented 5 years ago

I'm sorry that this has been affecting you for quite some time, now.

Please understand, however, that we've been considering this to be an edge-case issue (we've not had any other reports of people suffering from this in the wild), so it hasn't been prioritised vs other more pressing bugs/features.

However, given that I can recreate this, and that there's a likelihood that people often try to match the optimal image size, I suspect that this is probably affecting more people out in the wild. I've made some noise about it internally, which should hopefully result in it getting some attention (and hopefully, getting it fixed).

As to switching to one of those other plugins, well, it depends on how much of your organic traffic you'd be happy to lose ;)

mahnunchik commented 5 years ago

The error in this line https://github.com/Yoast/wordpress-seo/blob/4811c9e16a00fb100f5b4c621ddc9d93104708d2/inc/class-wpseo-image-utils.php#L158

mahnunchik commented 5 years ago

Hi @jono-alderson

The problem is in image_get_intermediate_size function of wordpress core https://github.com/WordPress/WordPress/blob/master/wp-includes/media.php#L770

Image metadata sizes doesn't contain size if it is exactly as original image.

jonoalderson commented 5 years ago

Ah, good find! That's definitely liable to cause headaches.

mahnunchik commented 5 years ago

I hope you may switch back image selection for og tag like for twitter. For twitter it works as expected.

mahnunchik commented 5 years ago

I've created ticket https://core.trac.wordpress.org/ticket/47713#ticket

mahnunchik commented 5 years ago

@jono-alderson original issue 7 years old... we need a work around https://core.trac.wordpress.org/ticket/21714

mahnunchik commented 5 years ago

@jono-alderson it is possible to replace image_get_intermediate_size by image_downsize. It has a bit different signature but returns original size.

https://developer.wordpress.org/reference/functions/image_downsize/

mahnunchik commented 5 years ago

@jono-alderson I've fixed wordpress core https://core.trac.wordpress.org/ticket/47713

monbauza commented 1 year ago

This issue was fixed in Yoast SEO 20.1. See https://github.com/Yoast/wordpress-seo/pull/19693. Closing.