Lasso Soft Inc. > Home

[gravatar_9]

Linkgravatar_9
AuthorJonathan Guthrie
CategoryUtility
Version9.x
LicensePublic Domain
Posted05 Nov 2010
Updated05 Nov 2010
More by this author...

Description

Retrieves the Gravatar for the given email address. Optionally accepts a rating, a size, and a link to a custom default icon

NOTE: a Lasso 9 port of the [gravatar] tag from Jason Huck

Sample Usage

gravatar('joe@schmoe.com', -size=80, -rating='G')

Source Code

Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.

define gravatar(email::string,-rating::string='',-default::string='',-size::integer=80) => {
//    Retrieves the Gravatar for the given email address.
 
	fail_if( 
		!valid_email(#email), 
		-1, 'Email address supplied is not valid.' 
	)
 
	fail_if( 
		#rating->size && array('G','PG','R','X') !>> #rating, 
		-1, 'Rating must be one of G, PG, R, or X.' 
	)
	
	fail_if( 
		#size < 1 || #size > 80, 
		-1, 'Size must be between 1 and 80.' 
	)
     
	fail_if( 
		#default->size && !valid_url(#default), 
		-1, 'Default must be a complete, valid URL.' 
	)
 
    local(hash = encrypt_md5(#email))
    local(url = 'http://www.gravatar.com/avatar.php?gravatar_id=' + #hash)
    #rating->size ? #url += '&rating=' + #rating
	#url += '&size=' + #size
	#default->size ? #url += '&default=' + encode_stricturl(#default)
    return(#url)     
}

Comments

No comments

Please log in to comment

Subscribe to the LassoTalk mail list

LassoSoft Inc. > Home

 

 

©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft