filter

jetpack_images_get_images

Filters the array of images that would be good for a specific post. This filter is applied after options ($args) filter the original array.

Parameters

$media
array

Array of images that would be good for a specific post.

$post_id
int

Post ID.

$args
array

Array of options to get images.

Changelog

How to use this hook

See “How to use actions and filters to customize Jetpack”.

Notes

You could use this filter to provide default images for Related Posts, or for any of the other Jetpack features picking images in your posts, like the Open Graph Meta Tags or the Top Posts module. Here is how to use the filter:
function jeherve_custom_image( $media, $post_id, $args ) {
    if ( $media ) {
        return $media;
    } else {
        $permalink = get_permalink( $post_id );
        $url = apply_filters( 'jetpack_photon_url', 'YOUR_FALLBACK_IMG_URL' );
      
        return array( array(
            'type'  => 'image',
            'from'  => 'custom_fallback',
            'src'   => esc_url( $url ),
            'href'  => $permalink,
            'alt'   => 'Alt description for your image',
        ) );
    }
}
add_filter( 'jetpack_images_get_images', 'jeherve_custom_image', 10, 3 );