I tried putting this snippet in my functions.php
add_filter( 'avatar_defaults', 'newgravatar' );
function newgravatar ($avatar_defaults) {
$myavatar = get_bloginfo('template_directory') . '/images/default_avatar.png';
$avatar_defaults[$myavatar] = "Locale";
return $avatar_defaults;
}
A new avatar appears in Options-Discussion. Problem is it’s not local at all.. the avatar is taken from http://i1.wp.com/mydomain.com/wp-content/themes/mytheme/images/default_avatar.png
.
So it passes through i1.wp.com
anyway.. how can I just have a friggin LOCAL link?
You have the Photon module enabled in the Jetpack plugin. That module routes your images through WordPress.com’s CDN. If you don’t want this to happen, disable the Photon module in Jetpack.
I’ve been looking up how to do this myself and that same function shown above everyone keeps suggesting isn’t working, perhaps due to a recent update to WP’s codebase, I’m not entirely sure. It’s a little hackish and it involves editing core files (not good) but it’s a work-around solution. Here’s the steps:
Scroll down to just above where the first IMG tag is outputted, you should see this:
Just under
$out
, add$out = $default;
This basically passes the default image source url (stored in the options table)So it should look like this:
Again, this isn’t ideal obviously because the next time you update WordPress, you’ll lose this change. But for the moment it works.
To future visitors looking to not modify core files, you may want to look into filtering the WP function
get_avatar
. It seems to do so would require modifying the string supplied in the filter with a regular expression to remove the gravatar domain. I attempted it but suck at regex. 😛