SHOW:
|
|
- or go back to the newest paste.
| 1 | /** | |
| 2 | - | * Apply Default Image for Jetpack |
| 2 | + | * Apply Default OG:Image for Jetpack |
| 3 | * When looking for images in posts that falls under "is_singular" | |
| 4 | * and Jetpack does not find an image, we apply our own default image | |
| 5 | * instead of the blank WordPress thumb. | |
| 6 | * @version 1.0 | |
| 7 | */ | |
| 8 | add_filter( 'jetpack_images_get_images', 'apply_default_image_for_jetpack_seo', 10, 3 ); | |
| 9 | function apply_default_image_for_jetpack_seo( $media, $post_id, $args ) {
| |
| 10 | // Jetpack_PostImages::get_images did not find anything | |
| 11 | if ( ! $media && is_singular() ) {
| |
| 12 | $media = array(); | |
| 13 | $media[] = array( 'src' => 'http://site.com/default.png' ); | |
| 14 | } | |
| 15 | return $media; | |
| 16 | } |