Skip to content

Instantly share code, notes, and snippets.

@webdados
Created September 26, 2017 09:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save webdados/ef5d5db01f01bee6041c2b2e0950d73a to your computer and use it in GitHub Desktop.
Save webdados/ef5d5db01f01bee6041c2b2e0950d73a to your computer and use it in GitHub Desktop.
Using the fb_og_image_additional filter on Facebook Open Graph, Google+ and Twitter Card Tags for WordPress
<?php
add_filter( 'fb_og_image_additional', 'extra_preview_images' );
function extra_preview_images( $fb_image_additional ) {
//You could/should use your own logic to decide which images to return. This example only shows you the structure of the array you should return.
if ( !is_array( $fb_image_additional ) ) {
$fb_image_additional = array();
}
$fb_image_additional[] = array(
'fb_image' => 'https://domain.com/wp-content/uploads/og_image2.jpg',
'png_overlay' => true, //Overlay PNG
);
$fb_image_additional[] = array(
'fb_image' => 'https://domain.com/wp-content/uploads/og_image3.jpg',
'png_overlay' => false, //Do not overlay PNG
);
return $fb_image_additional;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment