Jetpack Custom Fallback Image

Last updated 2 months ago

PHP
function hlabs_custom_image( $media, $post_id, $args ) {
	if ( empty( $media ) ) {
		$permalink = get_permalink( $post_id );
		$url = apply_filters( 'jetpack_photon_url', 'YOUR_LOGO_IMG_URL' );
	
		return array( array(
			'type'	=> 'image',
			'from'	=> 'custom_fallback',
			'src'	=> esc_url( $url ),
			'href'	=> $permalink,
		) );
	}
}
add_filter( 'jetpack_images_get_images', 'hlabs_custom_image', 10, 3 );

All code snippets are licensed GPLv2 or later unless otherwise stated.