Hi,
Is there any way we can implement height and width in og:image? The importance of this is to allow facebook to precache the image if these are correctly set.
more info here:
https://developers.facebook.com/docs/sharing/best-practices
thanks
Hi Sam,
This is (only) an issue for the first person who shares the page/post.
Nevertheless, I'll see if I can implement this feature in the near future :).
I'll keep you updated right here once more on this issue is known.
Thanks for the fast reply, yep that is exactly what i need to do!
Done!
See: https://github.com/sybrew/the-seo-framework/commit/d020cdcf0d5fa12d4d1aa30b68411c938f5d2c31
It will output the image width and height beneath every found image, and it's done according to the Array syntax.
It works on the default OG Image, and each WooCommerce Product Gallery image.
Supported image modules:
It will be included in the 2.7.0 release :).
Thank you for this feature!
Quick question.
If I don't have a featured image present, I set the og:image with:
// Set default og:image if featured image not present
add_filter( 'the_seo_framework_og_image_args', 'my_awesome_og_image' );
function my_awesome_og_image( $args ) {
if(!has_post_thumbnail()) {
$args['image'] = home_url( '/FbShare_1200x630.png' );
}
return $args;
}
Is there a way to pass the width and height by this filter or another filter?
maybe with $args['attr] ?
Thanks
Hi Lari,
I believe this is best achieved through adjusting the property $image_dimensions.
This is already possible :).
Untested (JIT) example, but here's the idea:
// Set default og:image if featured image not present
add_filter( 'the_seo_framework_og_image_args', 'my_super_awesome_og_image' );
function my_super_awesome_og_image( $args ) {
if( ! has_post_thumbnail() ) {
$args['image'] = home_url( '/FbShare_1200x630.png' );
//* Match the Post/Page/Term ID that's checked for (first and default image only).
$id = the_seo_framework()->get_the_real_ID();
the_seo_framework()->image_dimensions[ $id ] = array(
'width' => '1200',
'height' => '630',
);
}
return $args;
}
Looks like it works just by copypasting your code. Thank you again!
Most helpful comment
Hi Lari,
I believe this is best achieved through adjusting the property
$image_dimensions.This is already possible :).
Untested (JIT) example, but here's the idea: