Yoast / wordpress-seo

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

Not always able to use `wpseo_opengraph_image` filter for adding `og:image` #15721

Open pattonwebz opened 4 years ago

pattonwebz commented 4 years ago

Please give us a description of what happened.

The wpseo_opengraph_image filter is not always reachable if no featured image or default image is added. This means ogimage cannot reliably be added to posts using the filter.

Please describe what you expected to happen and why.

Ability to use the wpseo_opengraph_image filter to add images when no default image is set, no featured image is set and post_content contains no image.

How can we reproduce this behavior?

  1. Clear the default facebook share image.
  2. Ensure no featured image is set on a post and that post_content contains no image.
  3. Try add an image via the wpseo_opengraph_image filter.
  4. See that no og:image tag is added.

Technical info

Used versions

pattonwebz commented 4 years ago

I was mistaken when I opened this issue with the version of the plugin we have in use. We are using premium version in the site I experienced this on and code in premium seems to be out of sync with free where depreciated files exist here but not yet drpricated in pro. I'll close this issue here for now.

pattonwebz commented 4 years ago

Reopening this issue as I confirmed it still exists in 14.6 version of the free plugin.

I did workout a solution for this issue for 14.5 premium plugin but code here is quite different to the code in that and it does not transfer over 1:1. I am happy to share that solution though with someone if they wanted to transition it to the updated codebase here.

Djennez commented 4 years ago

Yea, it's a known issue (https://github.com/Yoast/wordpress-seo/issues/15523#issuecomment-654706733) but it didn't have its own dedicated issue thread yet, so happy to keep this open.

pattonwebz commented 4 years ago

@Djennez thanks for letting me know and adding the tags.

I did happen to work out a code solution for this in the premium plugin that only required a very minor logic rework in a single method. Sadly the code here in free is really quite different and the file I modified there has been depricated here already. Let me know if there is a way to share that solution with you and I can send it through so it could be replicated here by someone.

zackkatz commented 4 years ago

This is also affecting us at GravityView. We need the wpseo_opengraph_image filter to be run, as it previously was.

benklocek commented 4 years ago

This also seems to affect the wpseo_schema_main_image filter.

RedCardinal commented 4 years ago

Just to add here, this issue is affecting multiple client sites using Yoast Premium. The outcome is that we randomly and often have no OG:image tags, and given these are all national news sites publishing syndicated content at a high velocity (which rely heavily on social sharing), we hope a fix is forthcoming please.

benmay commented 4 years ago

+1 following

michaelbriantina commented 2 years ago

https://wordpress.org/support/topic/wpseo_opengraph_image-filter-not-working-2/

jessebrightman commented 2 years ago

same here, posts are created programmatically without using the WP Image API so it is imperative to be able to add the og:image tag programmatically also

waltercruz commented 1 year ago

any news about this issue?

waltercruz commented 1 year ago

My usage: in the template where i'm working, we mostly set the post thumbnail only for pages that are direct children of the site, and any pages below that just use the same image from the parent.

The share on the parents work well, but I would like to set the images on children to be the same of the parent on share too, using just a filter, without having to set the post thumbnail on each children.

khalilr2k commented 3 months ago

I got something, this filter work as should be when the Yoast premium is active