This should still work, the filter still exists. If that doesn’t seem to work on your site, could you let me know where you’ve added this code, and give me a few examples of posts where a fallback image should be displayed, but isn’t?
Thanks!
I have added this code:
function jeherve_custom_image( $media, $post_id, $args ) {
if ( $media ) {
return $media;
} else {
$permalink = get_permalink( $post_id );
$url = apply_filters( 'jetpack_photon_url', 'http://ecre.org/images/ecre.jpg' );
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 );
—–
in the function file, I’m using child theme for Divi theme.
I tried to post the links on the facebook and twitter:
https://twitter.com/ecre/status/742989794972733440
Thank you for you help.
Your site appears to be down at the moment:
http://i.wpne.ws/gSai
Could you let me know as soon as it’s back up, so I can take a closer look?
Thanks!
Thank you!
Could you try to remove the code from your child theme’s functions.php file, and move it to a functionality plugin like this one instead?
https://wordpress.org/plugins/code-snippets/
Let me know how it goes.
Hello Jeremy,
Thank you so much for replying.
I have done it: http://image.prntscr.com/image/67c69c5ec20b4b529b8b3a3d97537bd3.png
Just tested it on facebook and twitter and it is still not working. Does it need sometime to affect?
Thanks in advanced.
Excellent! It’s working now. You can see by viewing the source code on your site; you’ll see that the Open Graph Image Tag has changed to use your fallback image:
http://i.wpne.ws/gTOy
You should be all set!
Hi Jeremy,
You are right, it’s in the source, but It’s not on the socialmedia:
http://image.prntscr.com/image/b703669af2894f0ca73c3c6d343aad26.png
Thanks a lot
That’s to be expected, as both Twitter and Facebook cache the Meta Tags for a little while.
You can’t force Twitter to flush its cache, but you can use Facebook Debug to ask Facebook to crawl the post again:
https://developers.facebook.com/tools/debug/og/object?q=http%3A%2F%2Fwww.ecre.org%2Fresettlement-urgently-needed%2F
To do so, just click on the “Fetch New Scrape Information” button. Once you’ve done so, images will be displayed properly when you share a post on Facebook.
It’s worth noting that old Facebook posts won’t change though. Once a post has been shared on Facebook, the preview doesn’t change.
Thanks a lot.
Everything works perfect now!!