You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've searched for any related issues and avoided creating a duplicate issue.
Please give us a description of what happened.
Expected results:
I have a fallback OG image in the Yoast settings.
When I don't have a featured image on that page, then both twitter and og get the url.
Strange results:
I have a fallback OG image in the Yoast settings.
If there is a featured image BUT it's not displayed on the page (used for archives) then the OG image is the fallback but the Twitter image is the featured image assigned but not displayed.
What I would expect is that both the OG and the Twitter image get the featured image whether or not it's displayed on the page.
Please describe what you expected to happen and why.
See above.
How can we reproduce this behavior?
See first.
Technical info
Latest all. Not using Gutenberg. N/A.
The text was updated successfully, but these errors were encountered:
add_filter( 'wpseo_opengraph_image', 'filter_wpseo_opengraph_image', 10, 1 );
/**
* Opengraph Social Image from Featured Image
* If user does not enter a social image AND the page has a featured image, use that
* otherwise use the default assigned in settings.
* Won't work unless a default image is set via the settings in Yoast.
*/
function filter_wpseo_opengraph_image( $img ) {
global $post;
if( isset( $post ) && has_post_thumbnail() ) :
$og = get_post_meta( $post->ID, '_yoast_wpseo_opengraph-image', true );
if ( empty( $og ) ) :
$img = get_the_post_thumbnail_url( $post->ID, 'facebook-instagram' );
else:
$img = $og;
endif;
endif;
return $img;
}
add_filter( 'wpseo_twitter_image', 'filter_wpseo_twitter_image', 10, 1 );
/**
* Twitter Social Image from Featured Image
* If user does not enter a social image AND the page has a featured image, use that
* otherwise use the default assigned in settings.
*/
function filter_wpseo_twitter_image( $img ) {
global $post;
if( isset( $post ) && has_post_thumbnail() ) :
$tw = get_post_meta( $post->ID, '_yoast_wpseo_twitter-image', true );
if ( empty( $tw ) ) :
$img = get_the_post_thumbnail_url( $post->ID, 'facebook-instagram' );
else:
$img = $tw;
endif;
endif;
return $img;
}
Hi @carasmo, thanks for your report and analysis. The Twitter and Facebook meta images are calculated via different systems and I agree that this causes strange behavior. I'll ask our product team to determine if this is something that we want to change so that they behave more consistently.
Please give us a description of what happened.
Expected results:
Strange results:
What I would expect is that both the OG and the Twitter image get the featured image whether or not it's displayed on the page.
Please describe what you expected to happen and why.
See above.
How can we reproduce this behavior?
See first.
Technical info
Latest all. Not using Gutenberg. N/A.
The text was updated successfully, but these errors were encountered: