mrg_get_avatar

The M Retina Gravatars mrg get avatar function.

Description

mrg_get_avatar( $avatar, $id_or_email, $size, $default, $alt ); 

Parameters (5)

0. $avatar
The avatar.
1. $id_or_email
The id or email.
2. $size
The size.
3. $default
The default.
4. $alt
The alt.

Usage

  1. if ( !function_exists( 'mrg_get_avatar' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'm-retina-gravatars/retina-gravatars.php'; 
  3.  
  4. // The avatar. 
  5. $avatar = null; 
  6.  
  7. // The id or email. 
  8. $id_or_email = null; 
  9.  
  10. // The size. 
  11. $size = null; 
  12.  
  13. // The default. 
  14. $default = null; 
  15.  
  16. // The alt. 
  17. $alt = null; 
  18.  
  19. // NOTICE! Understand what this does before running. 
  20. $result = mrg_get_avatar($avatar, $id_or_email, $size, $default, $alt); 
  21.  

Defined (1)

The function is defined in the following location(s).

/retina-gravatars.php  
  1. function mrg_get_avatar($avatar, $id_or_email, $size, $default, $alt) { 
  2. $retina_size = absint($size) * 2; 
  3.  
  4. $size_argument = '?s=' . $size; 
  5. $size_retina_argument = '?s=' . $retina_size; 
  6.  
  7. // replace size for avatar 
  8. $avatar = preg_replace('/' . preg_quote($size_argument) . '/', $size_retina_argument, $avatar); 
  9. // replace size for default avatar 
  10. $avatar = preg_replace('/' . preg_quote(urlencode($size_argument)) . '/', urlencode($size_retina_argument), $avatar); 
  11.  
  12. return $avatar;