kuzzmi / elm-gravatar / Gravatar

Returns URL or img DOM element for a given email, uses options as query parameters with URL. More about query parameters read at Gravatar website.

Gravatar image

img : Options -> String -> Html msg

Returns img DOM element which points to Gravatar for a given email and using options as query parameters with URL

img defaultOptions "kuzzmi@example.com"
-- returns image node with 200px x 200px image
-- for "kuzzmi@example.com" email.

url : Options -> String -> String

Returns URL which points to Gravatar for a given email and using options as query parameters with URL

url defaultOptions "kuzzmi@example.com"
-- returns url to 200px x 200px image
-- for "kuzzmi@example.com" email.

let
    options =
        defaultOptions
            |> withDefault Retro
            |> forceDefault
in
url options "kuzzme@example.com"
-- url to 200 x 200 image in the 'retro' format

Options


type alias Options =
{ size : Maybe Basics.Int
, default : Default
, rating : Rating
, forceDefault : Basics.Bool 
}

Allows specifying all the options you could possibly need for gravatar urls.

Full overview of what the options do.

defaultOptions : Options

Default options. Passing these results in passing no options in the final url at all.


type Default
    = None
    | Url String
    | FourOhFour
    | MysteryMan
    | Identicon
    | MonsterID
    | Wavatar
    | Retro
    | Blank

By default, if there is no (allowed) image associated with an emailaddress, gravatar will display the gravatar logo. However, there are other fallback images, too. For more explanation about these, please see the gravatar docs.


type Rating
    = RatedG
    | RatedPG
    | RatedR
    | RatedX

Gravatar allows adding "rating" meta-data to its avatars. By default, you will only get G-rated images. For more information, please see the gravatar docs.

withSize : Maybe Basics.Int -> Options -> Options

Sets the size to the passed in value.

defaultOptions |> withSize (Just 80)
--> { size = Just 80, ... }

withRating : Rating -> Options -> Options

Sets the rating to the passed in value.

defaultOptions |> withRating RatedPG
--> { rating = RatedPG, ... }

withDefault : Default -> Options -> Options

Sets the default to the passed in value.

defaultOptions |> withDefault Retro
--> { default = Retro, ... }

forceDefault : Options -> Options

Enables the forceDefault flag.

defaultOptions |> forceDefault
--> { forceDefault = True, ... }