Zend Framework  3.0
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
Gravatar Class Reference

Helper for retrieving avatars from gravatar.com. More...

Public Member Functions

 __invoke ($email="", $options=[], $attribs=[])
 Returns an avatar from gravatar's service.
 
 __toString ()
 Return valid image tag.
 
 setOptions (array $options)
 Configure state.
 
 getImgTag ()
 Return valid image tag.
 
 setAttribs (array $attribs)
 Set attribs for image tag.
 
 getAttribs ()
 Get attribs of image.
 
 setDefaultImg ($defaultImg)
 Set default img.
 
 getDefaultImg ()
 Get default img.
 
 setEmail ($email)
 Set email address.
 
 getEmail ()
 Get email address.
 
 setImgSize ($imgSize)
 Set img size in pixels.
 
 getImgSize ()
 Get img size.
 
 setRating ($rating)
 Set rating value.
 
 getRating ()
 Get rating value.
 
 setSecure ($flag)
 Load from an SSL or No-SSL location?
 
 getSecure ()
 Get an SSL or a No-SSL location.
 
- Public Member Functions inherited from AbstractHtmlElement
 getClosingBracket ()
 Get the tag closing bracket.
 
- Public Member Functions inherited from AbstractHelper
 setView (Renderer $view)
 Set the View object.
 
 getView ()
 Get the view object.
 

Public Attributes

const GRAVATAR_URL = 'http://www.gravatar.com/avatar'
 URL to gravatar service.
 
const GRAVATAR_URL_SECURE = 'https://secure.gravatar.com/avatar'
 Secure URL to gravatar service.
 
const RATING_G = 'g'
 Gravatar rating.
 
const RATING_PG = 'pg'
 
const RATING_R = 'r'
 
const RATING_X = 'x'
 
const DEFAULT_404 = '404'
 Default gravatar image value constants.
 
const DEFAULT_MM = 'mm'
 
const DEFAULT_IDENTICON = 'identicon'
 
const DEFAULT_MONSTERID = 'monsterid'
 
const DEFAULT_WAVATAR = 'wavatar'
 
- Public Attributes inherited from AbstractHtmlElement
const EOL = PHP_EOL
 EOL character.
 

Protected Member Functions

 getAvatarUrl ()
 Get avatar url (including size, rating and default image options)
 
 getGravatarUrl ()
 Get URL to gravatar's service.
 
 setSrcAttribForImg ()
 Set src attrib for image.
 
- Protected Member Functions inherited from AbstractHtmlElement
 isXhtml ()
 Is doctype XHTML?
 
 htmlAttribs ($attribs)
 Converts an associative array to a string of tag attributes.
 
 normalizeId ($value)
 Normalize an ID.
 

Protected Attributes

 $attribs
 
 $email
 
 $emailIsHashed
 
 $options
 
- Protected Attributes inherited from AbstractHtmlElement
 $closingBracket = null
 
- Protected Attributes inherited from AbstractHelper
 $view = null
 

Detailed Description

Helper for retrieving avatars from gravatar.com.

Member Function Documentation

__invoke (   $email = "",
  $options = [],
  $attribs = [] 
)

Returns an avatar from gravatar's service.

$options may include the following:

  • 'img_size' int height of img to return
  • 'default_img' string img to return if email address has not found
  • 'rating' string rating parameter for avatar
  • 'secure' bool load from the SSL or Non-SSL location
See Also
http://pl.gravatar.com/site/implement/url
http://pl.gravatar.com/site/implement/url More information about gravatar's service.
Parameters
string | null$emailEmail address.
null | array$optionsOptions
array$attribsAttributes for image tag (title, alt etc.)
Returns
Gravatar
__toString ( )

Return valid image tag.

Returns
string
getAttribs ( )

Get attribs of image.

Warning! If you set src attrib, you get it, but this value will be overwritten in protected method setSrcAttribForImg(). And finally your get other src value!

Returns
array
getAvatarUrl ( )
protected

Get avatar url (including size, rating and default image options)

Returns
string
getDefaultImg ( )

Get default img.

Returns
string
getEmail ( )

Get email address.

Returns
string
getGravatarUrl ( )
protected

Get URL to gravatar's service.

Returns
string URL
getImgSize ( )

Get img size.

Returns
int The img size
getImgTag ( )

Return valid image tag.

Returns
string
getRating ( )

Get rating value.

Returns
string
getSecure ( )

Get an SSL or a No-SSL location.

Returns
bool
setAttribs ( array  $attribs)

Set attribs for image tag.

Warning! You shouldn't set src attrib for image tag. This attrib is overwritten in protected method setSrcAttribForImg(). This method(_setSrcAttribForImg) is called in public method getImgTag().

Parameters
array$attribs
Returns
Gravatar
setDefaultImg (   $defaultImg)

Set default img.

Can be either an absolute URL to an image, or one of the DEFAULT_* constants

More information about default image. string $defaultImg Gravatar

setEmail (   $email)

Set email address.

Parameters
string$email
Returns
Gravatar
setImgSize (   $imgSize)

Set img size in pixels.

Parameters
int$imgSizeSize of img must be between 1 and 512
Returns
Gravatar
setOptions ( array  $options)

Configure state.

Parameters
array$options
Returns
Gravatar
setRating (   $rating)
setSecure (   $flag)

Load from an SSL or No-SSL location?

Parameters
bool$flag
Returns
Gravatar
setSrcAttribForImg ( )
protected

Set src attrib for image.

You shouldn't set an own url value! It sets value, uses protected method getAvatarUrl.

If already exists, it will be overwritten.

Returns
void

Member Data Documentation

$attribs
protected
$email
protected
$emailIsHashed
protected
$options
protected
Initial value:
= [
'img_size' => 80
const DEFAULT_404 = '404'

Default gravatar image value constants.

const DEFAULT_IDENTICON = 'identicon'
const DEFAULT_MM = 'mm'
const DEFAULT_MONSTERID = 'monsterid'
const DEFAULT_WAVATAR = 'wavatar'
const GRAVATAR_URL = 'http://www.gravatar.com/avatar'

URL to gravatar service.

const GRAVATAR_URL_SECURE = 'https://secure.gravatar.com/avatar'

Secure URL to gravatar service.

const RATING_G = 'g'

Gravatar rating.

const RATING_PG = 'pg'
const RATING_R = 'r'
const RATING_X = 'x'