Hi @ayek
You can use the filter wpseo_opengraph_image to modify and add the image of your preference.
We have a developer portal with more information about filters and many examples of how to implement them.
Typically code snippets are added to your theme’s functions.php file. If you’re unfamiliar with using code snippets, we’d like to refer you to the WordPress documentation on how to use a filter.
We recommend creating regular backups of your site and database for your site’s health and safety. A backup is crucial before making important changes on your website and provides you with a safety net if something were to go wrong. Learn more about the benefits of regular backups.
This thread was marked resolved due to a lack of recent activity. The original poster can change the status to Not Resolved to re-open the issue or open a new topic.
If you are not the original poster but have a similar issue, please open a new topic.
Thread Starter
Rafał
(@ayek)
Hi
Sorry, I couldn’t find suitable method to allow AVIF in Social tab.
I use workaround which as OG:image gets featured image, even if it’s in AVIF format
add_filter('wpseo_opengraph_image', 'use_featured_image');
function use_featured_image($img) {
// Get the current post ID
$post_id = get_the_ID();
// Check if Yoast SEO has a social image set
$yoast_social_image = get_post_meta($post_id, '_yoast_wpseo_opengraph-image', true);
// Only use featured image if no Yoast social image is set
if (empty($yoast_social_image) && has_post_thumbnail($post_id)) {
$img = get_the_post_thumbnail_url($post_id, 'full');
}
return $img;
}