如何检查配置文件是否具有默认头像

时间:2018-02-19 04:52:44

标签: wordpress avatar gravatar

https://docs.mongodb.com/manual/tutorial/configure-x509-client-authentication/#addx509subjectuser

如果有默认的gravatar,我想隐藏个人资料。我尝试了很多代码,但它们并没有给我带来丰硕的成果。因为某些图像来自媒体文件夹,而某些图像来自“”。谁能告诉我如何检测这件事?

1 个答案:

答案 0 :(得分:1)

The get_avatar() returns An img element for the user's avatar or false on failure. The function does not output anything; you have to echo the return value.

Please try below code to check if the profile has a default avatar.

if(!get_the_author_meta('ID')){
        // no img code here     
        echo 'no img code';
    }else{
        $gavar_url = get_avatar_url( $user_email);
        if(strpos($gavar_url,'gravatar.com')!==false){
            //no image code here 
        }else{
            echo get_avatar( get_the_author_meta('ID') , 80);
        }
    }