gravatarの顔画像をリクエスト方法
会員制サイトなどで、Gravatarに登録してあるプロフィール画像を利用する方法です。
使い方
オプション
登録されていない場合にデフォルトの画像を表示させることも可能です。
以下のパラメータをHASH値の後に指定します
| param | Explanation | Image |
|---|---|---|
| 404 | do not load any image if none is associated with the email hash, instead return an HTTP 404 (File Not Found) response | 404 Not Found(文字列) |
| mm | (mystery-man) a simple, cartoon-style silhouetted outline of a person (does not vary by email hash) | ![]() |
| identicon | a geometric pattern based on an email hash | ![]() |
| monsterid | a generated 'monster' with different colors, faces, etc | ![]() |
| wavatar | generated faces with differing features and backgrounds | ![]() |
| retro | awesome generated, 8-bit arcade-style pixelated faces | ![]() |
| blank | a transparent PNG image (border added to HTML below for demonstration purposes) | ![]() |
例(Railsの場合)
<% hash = Digest::MD5.hexdigest(email_address) image_src = "http://www.gravatar.com/avatar/#{hash}?d=mm" %> <img src=<%= image_src %>>
これで指定されたemail_addressで画像が登録されている場合はその画像が表示され、
登録されていない場合はmm(mystery man)の画像が表示されます





