Introduction to Gravatar

Source: Internet
Author: User
Introduction to Gravatar: 1. what is Gravatar?

Gravatar is a service launched by www.gravatar.com, meaning "global avatar ". If you have registered an account on gravatar and placed an avatar on the gravatar server, you only need to provide an email address when you speak on a blog that supports gravatar, the avatar associated with the email is displayed. In this way, we provide a platform for you to manage multiple portraits in a unified manner. as long as the site supports gravatar, it is not necessary to upload portraits for each site separately, saving you trouble.

2. how to use Gravatar as a common user?

First, register an account on gravatar. you only need to enter a common email address, password, and then confirm in your mailbox. then, you have registered a gravatar account. Then, log on to gravatar with an account and add an avatar to the account. each email can be associated with an avatar. There are many ways to upload the avatar.

After uploading and processing an avatar, you need to select a level for the avatar. different levels will determine whether your avatar is displayed on the site. if your avatar is too restricted, in this case, only one default profile is displayed.

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

  • PG: It may include rude gestures, provocative clothes, a little foul talk, and slightly violent content.

  • R: it may contain content such as foul, violent, naked, or drug abuse.

  • X: may contain naked sex or violent content.

After adding the image, you still need to wait for review. generally, G is selected, and your image is not special and will soon pass. It takes about 10 minutes to slow down.

3. how to use Gravatar as a developer?

Gravatar not only provides avatar solutions for common users, but also provides some interfaces for developers to facilitate developers to call gravatar portraits and simple profiles contained in users' gravatar portraits. On the Gravatar homepage, you can find the developer documentation portal, which contains the documentation on how to use the gravatar interface. All URLs on Gravatar are based on the hash value of the email address. Both images and personal files are obtained by accessing the hash value of the email, which is the main way for the system to identify users. To ensure the consistency and accuracy of the hash value, follow these steps when generating the hash value:

  1. Remove the leading and trailing space characters from the email address.

  2. Convert all letters to lowercase letters first.

  3. Use the md5 algorithm to calculate the processed email hash value.

For example, take "MyEmailAddress@example.com" as an example (note that we assume that the user accidentally pressed a space at the end of the mailbox address), if we use md5 to encode the string directly, we will get the following content:

Echo md5 ("MyEmailAddress@example.com"); // "f9879d71855b5ff21e4963273a886bfc"

To process the same email address according to the process mentioned above, we can get a completely different computing 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 ")));

To obtain the generated hash value, you can request to obtain an image or a personal file. The image request URL is similar to the following:

Http://www.gravatar.com/avatar/has

For example, the following is a basic URL link.

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

If no size parameter is provided, the default image size is 80X80. However, you can pass a value through the s = or size = parameter (the image is square) and dynamically specify the Gravatar image size. You can request images of any size from 1px to 512px. it should be noted that the resolution of many user portraits is low, so the effect of large portraits may be poor.

What if an email address does not have a corresponding Gravatar profile picture? Gravatar returns the following default avatar:

If you need to use your default profile picture (which may be a Logo or other image), you can specify the URL address of your default image in the d = or default = parameter next to the image link. This URL link requires URL encoding to ensure the correctness of transmission.

You can refer to the following line of code for URL encoding of strings in PHP:

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

When you specify the default avatar, Gravatar will display the default avatar you specified when there is no corresponding avatar in the email hash value.

In addition to setting the default profile picture, Gravatar also provides a series of built-in parameter options as the default value. These built-in parameter options accept the hash value of the email address and use this hash value to generate the topic image. To enable these parameters, you only need to add the d = parameter to the image request and set the parameter value to the following:

  • 404: no avatar is loaded. If the email address hash value does not have the corresponding image, the system returns the 404 response (the file is not found)

  • Mm: simple, cartoon-style profile (not changed with the mailbox hash value ).

  • Identicon: a geometric pattern. its shape changes with the email hash value.

  • Monsterid: the "monster" Avatar generated by the program. The color and face will change as the email hash value changes.

  • Wavatar: face portraits generated by combining different faces and backgrounds.

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

If you need to use your default profile picture (which may be a Logo or other image), you can specify the URL address of your default image in the d = or default = parameter next to the image link. This URL link requires URL encoding to ensure the correctness of transmission.

You can refer to the following line of code for URL encoding of strings in PHP:

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

When you specify the default avatar, Gravatar will display the default avatar you specified when there is no corresponding avatar in the email hash value.

In addition to setting the default profile picture, Gravatar also provides a series of built-in parameter options as the default value. These built-in parameter options accept the hash value of the email address and use this hash value to generate the topic image. To enable these parameters, you only need to add the d = parameter to the image request and set the parameter value to the following:

404: no avatar is loaded. If the email address hash value does not have the corresponding image, the system returns the 404 response (the file is not found)

Mm: simple, cartoon-style profile (not changed with the mailbox hash value ).

Identicon: a geometric pattern. its shape changes with the email hash value.

Monsterid: the "monster" Avatar generated by the program. The color and face will change as the email hash value changes.

Wavatar: face portraits generated by combining different faces and backgrounds.

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

For some reason, you may need to forcibly display the default avatar. In this case, you can 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 classify their profile pictures, indicating whether they are suitable for a specific audience. Only G-level portraits are displayed by default, unless you want to see a higher-level profile picture. You can use the r = or rating = parameter to specify the parameter and request the profile picture of a specific rating. To allow G-or PG-level portraits, refer to the following instance settings.

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

You can mix all the preceding parameters to generate complex requests. For example, the following URL request is a Gravatar profile picture with a 200 pixel size classified as G or PG. if the corresponding mailbox hash value does not have an avatar, a 404 response is returned by default.

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

If you need to display the Gravatar profile picture on the SSL transmission page (for example, the URL page starting with HTTPS), you want Gravatar to be transmitted over SSL. otherwise, you will see an annoying security warning in your browser. To make a security request, you only need to replace the Gravatar request link with the link starting with the following. Https://secure.gravatar.com /... In addition, you only need to make sure that the start of the URL is the same as above.

Finally, we recommend a cartoon profile-based 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.