Skip to content

Instantly share code, notes, and snippets.

@psflannery
Created October 16, 2013 09:15
Show Gist options
  • Save psflannery/7004958 to your computer and use it in GitHub Desktop.
Save psflannery/7004958 to your computer and use it in GitHub Desktop.
From http://wordpress.org/support/topic/help-can-i-specify-a-defaultfallback-image?replies=1 Add a default fallback image to jetpack open graphif no image can be found in a post
function jeherve_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', 'jeherve_custom_image', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment