Created
January 30, 2014 00:14
-
-
Save gabrielmerovingi/8700040 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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