2015年1月28日 星期三

How one can Retrieve Your Gravatar Picture URL


Having a profile image also referred to as “avatar picture” is fairly important on-line. We add our greatest profile image on web sites and social websites for legitimacy, credibility and for individuals to raised acknowledge our on-line presence.


WordPress has its personal service to ship consumer profile footage, and it’s referred to as Gravatar. We will additionally incorporate this into our personal custom-made themes. This submit will stroll you thru a few approaches on how one can retrieve the profile picture from Gravatar.


Utilizing Gravatar


Let’s begin from the fundamentals. WordPress has a particular built-in perform, get_avatar, which permits us to retrieve the gravatar picture. This perform requires two parameters: the consumer ID or e mail, and the dimensions of the picture to show. Right here is an instance.



$user_id = get_the_author_meta('ID'); echo get_avatar($user_id, eighty);

Should you choose utilizing a consumer e-mail, fill the get_the_author_meta() perform with user_email:



$user_id = get_the_author_meta('user_email'); echo get_avatar($user_id, eighty);

Each examples will output the identical outcome: a consumer avatar picture with the dimensions of 80px. In my case, I’ll see my image.


But, the issue that I as soon as encounter with this perform is that the perform generates the entire picture; a full tag. Examine the code supply, and you must discover it as follows:



This makes issues somewhat bit tough for us, for instance, to insert further courses or an ID into the .


Alternatively, we will retrieve solely the picture URL, as an alternative of the aspect in full. As soon as we received the URL, we will add it to the with the customized courses or ID added.


How To Retrieve The Picture URL


First, we might want to create a brand new PHP perform in features.php of the WordPress


The post How one can Retrieve Your Gravatar Picture URL appeared first on DICKLEUNG DESIGN 2014.


沒有留言: