getGravatarURL

Typefunction
Dictionarylibrary.gravatar
LibraryGravatar
Syntax
get getGravatarURL(<pEmail>[, <pFileType>, <pSize>, <pRating>, <pDefaultImage>, <pForceDefault>])
Associationscom.livecode.library.gravatar
Summary

Get the URL to request a user's avatar in gravatar.

OSmac, windows, linux, ios, android
Platformsdesktop, mobile, web
Parameters
NameTypeDescription
pEmail

The user's email address.

pFileType

The extension of the image, by default this value is ".jpg"

pSize

By default, images render at 80 px by 80 px if no size parameter is provided. This parameter can be a number between 1 and 2048, however, keep in mind that many users have lower resolution images, so requesting larger sizes may result in pixelation / low quality images. (images are square)

pDefaultImageURL

When you include a default image, Gravatar will automatically serve up that image if there is no image associated with the requested email hash. There are a few conditions which must be met for default image URL:

  1. MUST be publicly available (e.g. cannot be on an intranet, on a local development machine, behind HTTP Auth or some other firewall etc). Default images are passed through a security scan to avoid malicious content.
  2. MUST be accessible via HTTP or HTTPS on the standard ports, 80 and 443, respectively.
  3. MUST have a recognizable image extension (jpg, jpeg, gif, png).
  4. MUST NOT include a querystring (if it does, it will be ignored).

In addition to allowing you to use your own image, Gravatar has a number of built in options which you can also use as defaults. Most of these work by taking the requested email hash and using it to generate a themed image that is unique to that email address. To use these options, just pass one of the following keywords as the d= parameter to an image request:

  • 404: do not load any image if none is associated with the email hash, instead return an HTTP 404 (File Not Found) response
  • mp: (mystery-person) 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
  • robohash: a generated robot with different colors, faces, etc
  • blank: a transparent PNG image
pRating

Gravatar allows users to self - assess their images so they can indicate whether an image is appropriate for a certain audience. By default, only images rated 'G' are displayed, unless you indicate that you would like to see higher ratings. Using this parameter, you can specify one of the following ratings to request images up to and including that rating :

  • g: suitable for display on all websites with any audience type.
  • pg: may contain rude gestures, provocatively dressed individuals, the lesser swear words, or mild violence.
  • r: may contain such things as harsh profanity, intense violence, nudity, or hard drug use.
  • x: may contain hardcore sexual imagery or extremely disturbing violence.

If the requested email hash does not have an image meeting the requested rating level, then the default image is returned (or the specified default, as per above)

pForceDefault

If for some reason you want to force the default image to always load, you can do so by setting this parameter to true.

Example
on mouseUp
   local tURL,tText, tError

   put URL tURL into tText
   put getGravatarURL("MyEmailAddress@example.com") into tURL
   put URL tURL into tText

   if tError is empty then
      set the text of widget "Circle Avatar" to tText
   end if
end mouseUp
on mouseUp
   set the filename of image "Avatar" to getGravatarURL("MyEmailAddress@example.com")
end mouseUp
Values
NameTypeDescription
return

The url to the corresponding avatar image.

Description

Use the getGravatarURL function to get the URL to request a user's avatar in gravatar.