Skip to content

Instantly share code, notes, and snippets.

@gabrielmerovingi
Created January 30, 2014 00:14
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 gabrielmerovingi/8700040 to your computer and use it in GitHub Desktop.
Save gabrielmerovingi/8700040 to your computer and use it in GitHub Desktop.
/**
* Apply Default OG:Image for Jetpack
* When looking for images in posts that falls under "is_singular"
* and Jetpack does not find an image, we apply our own default image
* instead of the blank WordPress thumb.
* @version 1.0
*/
add_filter( 'jetpack_images_get_images', 'apply_default_image_for_jetpack_seo', 10, 3 );
function apply_default_image_for_jetpack_seo( $media, $post_id, $args ) {
// Jetpack_PostImages::get_images did not find anything
if ( ! $media && is_singular() ) {
$media = array();
$media[] = array( 'src' => 'http://site.com/default.png' );
}
return $media;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment