i1.wp.com url problem (Jetpack not installed)
-
13-04-2021 - |
Question
I added the following code to the functions.php file
add_filter( 'avatar_defaults', 'new_gravatar' );
function new_gravatar ($avatar_defaults) {
$myavatar = 'link';
$avatar_defaults[$myavatar] = "name";
return $avatar_defaults;
I'm taking the profile picture from my own server. But there is a problem!
"I1.wp.com" appears at the beginning of the url in the profile image. What is the reason? So it looks like: "https://i1.wp.com/mysite.com/images/myavatar.png"
I've disabled all plugins. But the result was not successful.
I'm dealing with it in days. How do we delete wp.com at the beginning of Url?
La solution
I found the answer to your question.
I've created a simple avatar plugin. (I edited and developed the code)
if ( !function_exists( 'get_avatar' ) ) :
function get_avatar( $id_or_email, $size = '0', $default = '', $alt = false ) {
if ( ! get_option('show_avatars') )
return false;
static $default_url;
if ( !isset( $default_url ) ) $default_url = 'http://example.com/image/my-image.png' ;
if ( false === $alt)
$safe_alt = '';
else
$safe_alt = esc_attr( $alt );
if ( !is_numeric( $size ) )
$size = '0';
$avatar = "<img alt='{$safe_alt}' src='{$default_url}' class='avatar avatar-{$size} photo avatar-default' height='{$size}' width='{$size}' />";
return apply_filters( 'get_avatar', $avatar, $id_or_email, $size, $default, $alt );
}
endif;
function __limit_default_avatars_setting( $default )
{
}
add_filter( 'avatar_defaults', '__limit_default_avatars' );
?>
I chose to take the image directly from the directory.
get_template_directory_uri()
instead
$default_url =
it was logical to use this code. because the other is redirecting to wordpress cdn url. (just like in emoji and svg profiles)