Created
April 12, 2018 02:23
-
-
Save rodgtr1/34da45a6f818ca7efcedb976285a9d1c to your computer and use it in GitHub Desktop.
Create Default Fallback Image For Jetpack Related Posts
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
function jp_custom_image( $media, $post_id, $args ) { | |
if ( $media ) { | |
return $media; | |
} else { | |
$permalink = get_permalink( $post_id ); | |
$url = apply_filters( 'jetpack_photon_url', 'https://example.com/wp-content/uploads/2017/07/example-image.jpg' ); | |
return array( array( | |
'type' => 'image', | |
'from' => 'custom_fallback', | |
'src' => esc_url( $url ), | |
'href' => $permalink, | |
) ); | |
} | |
} | |
add_filter( 'jetpack_images_get_images', 'jp_custom_image', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment