jetpack_og_get_image_gravatar

Gets a gravatar URL of the specified size.

Description

(array|bool|mixed|string) jetpack_og_get_image_gravatar( $email, $width ); 

Returns (array|bool|mixed|string)

Parameters (2)

0. $email
The email.
1. $width
The width.

Usage

  1. if ( !function_exists( 'jetpack_og_get_image_gravatar' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'jetpack-by-wordpress-com/functions.opengraph.php'; 
  3.  
  4. // The email. 
  5. $email = null; 
  6.  
  7. // The width. 
  8. $width = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = jetpack_og_get_image_gravatar($email, $width); 
  12.  

Defined (1)

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

/functions.opengraph.php  
  1. function jetpack_og_get_image_gravatar( $email, $width ) { 
  2. $image = ''; 
  3. if ( function_exists( 'get_avatar_url' ) ) { 
  4. $avatar = get_avatar_url( $email, $width ); 
  5. if ( ! empty( $avatar ) ) { 
  6. if ( is_array( $avatar ) ) 
  7. $image = $avatar[0]; 
  8. else 
  9. $image = $avatar; 
  10. } else { 
  11. $has_filter = has_filter( 'pre_option_show_avatars', '__return_true' ); 
  12. if ( !$has_filter ) { 
  13. add_filter( 'pre_option_show_avatars', '__return_true' ); 
  14. $avatar = get_avatar( $email, $width ); 
  15.  
  16. if ( !$has_filter ) { 
  17. remove_filter( 'pre_option_show_avatars', '__return_true' ); 
  18.  
  19. if ( !empty( $avatar ) && !is_wp_error( $avatar ) ) { 
  20. if ( preg_match( '/src=["\']([^"\']+)["\']/', $avatar, $matches ) ) 
  21. $image = wp_specialchars_decode($matches[1], ENT_QUOTES); 
  22.  
  23. return $image;