以下の内容はhttps://portaltan.hatenablog.com/entry/2016/01/06/142344より取得しました。


gravatarの顔画像をリクエスト方法

会員制サイトなどで、Gravatarに登録してあるプロフィール画像を利用する方法です。

使い方

リクエスト先

http://www.gravatar.com/avatar/HASH
  • HASHはgravatarに登録してあるemail addressをMD5変換したものを使用します

オプション

登録されていない場合にデフォルトの画像を表示させることも可能です。
以下のパラメータを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) f:id:portaltan:20160106142105j:plain
identicon a geometric pattern based on an email hash f:id:portaltan:20160106142114p:plain
monsterid a generated 'monster' with different colors, faces, etc f:id:portaltan:20160106142125p:plain
wavatar generated faces with differing features and backgrounds f:id:portaltan:20160106142137p:plain
retro awesome generated, 8-bit arcade-style pixelated faces f:id:portaltan:20160106142206p:plain
blank a transparent PNG image (border added to HTML below for demonstration purposes) f:id:portaltan:20160106142222p:plain


例(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)の画像が表示されます




以上の内容はhttps://portaltan.hatenablog.com/entry/2016/01/06/142344より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14