Introduction to Global Avatar Gravatar

Source: Internet
Author: User
1. What is Gravatar?

Gravatar is a service launched by www.gravatar.com, meaning "global Avatar". If the account is registered on the Gravatar and the avatar is placed on the Gravatar server, then when you speak on a blog that supports Gravatar, you can display an avatar that is associated with email as long as you provide an email address. This will provide you with a unified management of multiple Avatar platform, as long as the site support Gravatar, you do not have to specifically for each site to upload a separate avatar, eliminating the hassle.

2, as a normal user, how to use Gravatar?

First to Gravatar registered account, just fill out a common email address, fill in the password, and then to confirm in the mailbox, registered a Gravatar account. Then use the account login Gravatar, you can start to add an avatar for the account, each email can be associated with an avatar, upload avatar in a variety of ways.

Upload processed avatar I need to select a level for the avatar, different levels will determine whether your avatar is displayed in the site, if your avatar is too restrictive, it will not be displayed in the site does not support this level, but will only display a default avatar.

    • G: Suitable for all audience types on all sites.

    • PG: May contain rude gestures, provocative attire, a dash of foul language, and minor violence.

    • R: May contain profanity, extreme violence, nudity or drug addiction.

    • X: May contain naked sex or extreme violence content.

After the addition of the need to wait for approval, the general choice of G, and your picture nothing special, soon passed. It's about 10 minutes in a slow situation.

3, as the development of this, how to use Gravatar?

Gravatar not only provides an avatar solution for ordinary users, but also provides developers with interfaces to make it easy for developers to invoke Gravatar avatars and simple profiles included in the user's Gravatar avatar. In the Gravatar home page you can find the portal to the developer documentation, which contains documentation on how to use the Gravatar interface. All URLs on Gravatar are based on the hash value of the e-mail address. Images and personal files are accessed through the hash of the email, which is the primary way for the system to identify the user. To ensure the consistency and accuracy of the hashes, the following steps should be followed when generating the hash values:

    1. Remove the space between the tail and the email address.

    2. First, all letters are forcibly converted to lowercase letters.

    3. Computes the processed e-mail hash value using the MD5 algorithm.

For example, take the example of "MyEmailAddress@example.com" (note that we assume that the user accidentally presses a space at the end of the e-mail address), and if we encode the string directly with MD5, we get the following:

echo MD5 ("MyEmailAddress@example.com"); "F9879D71855B5FF21E4963273A886BFC"

Using the process mentioned above to process the same email address, you can get a completely different result:

$ email = Trim ("MyEmailAddress@example.com"); "MyEmailAddress@example.com"

$ email = strtolower ($ email); "Myemailaddress@example.com"

Echo MD5 ($ email); "0bc83cb571cd1c50ba6f3e8a78ef1346"

The above code can be written as a line of code:

echo MD5 (Strtolower ("Trim (" MyEmailAddress@example.com "));

Get the generated hash value and you can request an image or personal file. The picture request URL form resembles the following:

http://www.gravatar.com/avatar/Hash value

For example, here is a basic URL link.

Http://www.gravatar.com/avatar/205e460b479e2e5b48aec07710c08d50

If no size parameter is provided, the image size defaults to 80x80. However, you can pass a value (the image is square) through the s= or size= parameter, dynamically stipulating the Gravatar image size. You can request images of any size from 1px to 512px, and you need to point out that many user avatars have a lower resolution, so a large avatar may be less effective.

What happens if an email address doesn't have a corresponding Gravatar avatar? Gravatar will return the following default avatar:

If you need to use your default avatar (perhaps a logo, etc.), you can specify the URL of your own default image in the d= or default= parameter that follows the image link. This URL link needs to be URL encoded to ensure the correctness of the transmission.

How to URL encode a string in PHP, you can see this line of code:

echo urlencode (' http://example.com/images/avatar.jpg ');

When you specify a default avatar, Gravatar displays the default avatar you specify when the email hash does not have a corresponding avatar.

In addition to setting the default avatar, Gravatar also provides a series of built-in parameter options as default values. This type of built-in parameter option accepts the hash value of the e-mail address and uses that hash value to generate the theme picture. To enable these parameters, you simply add the d= parameter to the picture request and set the parameter value to the following values:

    • 404: Do not load any avatar. Returns a 404 response if the e-mail address hash value does not have a corresponding image (file not found)

    • MM: Simple, cartoon-style character silhouette (does not change with the mailbox hash value).

    • Identicon: A geometric pattern whose shape changes with the e-mail hash value.

    • Monsterid: The program-generated "monsters" avatar, colors and faces will vary with the e-mail hash value.

    • Wavatar:: A face picture created from a combination of different faces and backgrounds.

    • Retro: 8-bit arcade pixel avatar generated by the program.

If you need to use your default avatar (perhaps a logo, etc.), you can specify the URL of your own default image in the d= or default= parameter that follows the image link. This URL link needs to be URL encoded to ensure the correctness of the transmission.

How to URL encode a string in PHP, you can see this line of code:

echo urlencode (' http://example.com/images/avatar.jpg ');

When you specify a default avatar, Gravatar displays the default avatar you specify when the email hash does not have a corresponding avatar.

In addition to setting the default avatar, Gravatar also provides a series of built-in parameter options as default values. This type of built-in parameter option accepts the hash value of the e-mail address and uses that hash value to generate the theme picture. To enable these parameters, you simply add the d= parameter to the picture request and set the parameter value to the following values:

404: Do not load any avatar. Returns a 404 response if the e-mail address hash value does not have a corresponding image (file not found)

MM: Simple, cartoon-style character silhouette (does not change with the mailbox hash value).

Identicon: A geometric pattern whose shape changes with the e-mail hash value.

Monsterid: The program-generated "monsters" avatar, colors and faces will vary with the e-mail hash value.

Wavatar:: A face picture created from a combination of different faces and backgrounds.

Retro: 8-bit arcade pixel avatar generated by the program.

For some reason, you may need to force the default avatar to appear. You can then use the f= or forcedefault= parameter and set the parameter value to Y.

Http://www.gravatar.com/avatar/205e460b479e2e5b48aec07710c08d50?f=y

Gravatar allows users to grade their avatar to indicate whether the avatar is suitable for a particular audience. Only the G-level avatar is displayed by default, unless you want to see a higher-rated avatar. You can use the r= or rating= parameter to specify parameters that request a specific rated avatar. To allow a G or PG-level avatar, you can refer to the following instance settings.

Http://www.gravatar.com/avatar/205e460b479e2e5b48aec07710c08d50?r=pg

You can mix all of the above parameters to generate complex requests. For example, the following URL request is a 200-pixel size, rated G or PG-level Gravatar avatar, if the corresponding mailbox hash does not have an avatar, the default return 404 response.

http://www.gravatar.com/avatar/205e460b479e2e5b48aec07710c08d50?s=200&r=pg&d=404

If you need to display the Gravatar avatar (such as the URL page at the beginning of HTTPS) on the SSL-transmitted page, you want the Gravatar to be transmitted over SSL, and if not, you'll see the browser prompting for annoying security warnings. To make a security request, simply replace the Gravatar request link with a link at the beginning of the following. https://secure.gravatar.com/... In addition, as usual, you just need to make sure the URL starts with the same.

Finally recommend a cartoon avatar made of the site http://www.faceyourmanga.com/

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.