Advertisement
Guest User

Jetpack: Apply Default Image

a guest
Jan 21st, 2014
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.60 KB | None | 0 0
  1. /**
  2.  * Apply Default 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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement