ns_get_avatar

The NextScripts: Social Networks Auto-Poster ns get avatar function.

Description

ns_get_avatar( $avatar, $id_or_email, (int) $size = 96, (string) $default = '', (string) $alt = '' ); 

Parameters (5)

0. $avatar
The avatar.
1. $id_or_email
The id or email.
2. $size — Optional. (int) => 96
The size.
3. $default — Optional. (string) => ''
The default.
4. $alt — Optional. (string) => ''
The alt.

Usage

  1. if ( !function_exists( 'ns_get_avatar' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'nextscripts-social-networks-auto-poster/nxs_functions.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 = 96; 
  12.  
  13. // The default. 
  14. $default = ''; 
  15.  
  16. // The alt. 
  17. $alt = ''; 
  18.  
  19. // NOTICE! Understand what this does before running. 
  20. $result = ns_get_avatar($avatar, $id_or_email, $size, $default, $alt); 
  21.  

Defined (1)

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

/nxs_functions.php  
  1. if (!function_exists("ns_get_avatar")) { function ns_get_avatar($avatar, $id_or_email, $size=96, $default='', $alt='') {  
  2. if ( is_object($id_or_email) ) {  
  3. if ($id_or_email->comment_agent=='SNAP' && stripos($id_or_email->comment_author_url, 'facebook.com')!==false) { $fbuID = str_ireplace('@facebook.com', '', $id_or_email->comment_author_email);  
  4. $avatar = "<img alt='{$id_or_email->comment_author}' src='https://graph.facebook.com/v2.3/$fbuID/picture' class='avatar avatar-{$size} photo avatar-default' height='{$size}' width='{$size}' />"; } 
  5. if (stripos($id_or_email->comment_agent, 'SNAP||')!==false && stripos($id_or_email->comment_author_url, 'twitter.com')!==false) { $fbuID = str_ireplace('SNAP||', '', $id_or_email->comment_agent); 
  6. $avatar = "<img alt='{$id_or_email->comment_author}' src='{$fbuID}' class='avatar avatar-{$size} photo avatar-default' height='{$size}' width='{$size}' />";  
  7.  
  8. return $avatar; 
  9. }}