I want to change the og:image that Yoast SEO generates, to some custom height and width (eg 1200×630) because I’m uploading very large images. I’ve tried adding this code in functions.php but doesn’t work. Please help
function add_share_image_sizes() {
add_image_size( 'facebook-share', 1200, 630, true );
}
add_action( 'after_setup_theme', 'add_share_image_sizes' );
function set_yoast_facebook_share_image_size() {
return 'facebook-share';
}
add_filter( 'wpseo_opengraph_image_size', 'set_yoast_facebook_share_image_size' );
2
Answers
You need to pass a parameter.
Yoast has a filter to not handle images for og:image for 2Mb max. so you can update that by using a filter. Please add this code in your themes functions.php file.