cover_image_scr

The BuddyPress cover cover image scr function.

Description

cover_image_scr( (constant) $user_id = false ); 

Parameters (1)

0. $user_id — Optional. (constant) => false
The user id.

Usage

  1. if ( !function_exists( 'cover_image_scr' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress-cover/templates/default/theme.php'; 
  3.  
  4. // The user id. 
  5. $user_id = false; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = cover_image_scr($user_id); 
  9.  

Defined (1)

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

/templates/default/theme.php  
  1. function cover_image_scr($user_id=false) { 
  2. global $bp, $wpdb;  
  3. if(!$user_id&&$bp->displayed_user->id) 
  4. $user_id=$bp->displayed_user->id;  
  5. if(empty($user_id)) 
  6. return false; 
  7. $activity_table = $wpdb->prefix."bp_activity"; 
  8. $activity_meta_table = $wpdb->prefix."bp_activity_meta";  
  9. $sql = "SELECT a.*, am.meta_value FROM $activity_table a INNER JOIN $activity_meta_table am ON a.id = am.activity_id WHERE a.user_id = $user_id AND meta_key = 'bp_cover_activity' ORDER BY a.date_recorded DESC";  
  10. $pics = $wpdb->get_results($sql, ARRAY_A); 
  11.  
  12. $avatar_options = array ( 'type' => 'full', 'id' => 'user-profile-image', 'class' => 'img-rounded profile-user-photo');  
  13. $avatar = bp_cover_avatar_box( $avatar_options ); 
  14. $image=get_user_meta($user_id, 'bp_cover', true); 
  15. $author_id = get_current_user_id(); 
  16. $pos=get_user_meta($user_id, 'bp_cover_position', true); 
  17. $cover_profile = get_option( 'bp_cover_profile' ); 
  18. $filter = '<input id="id" name="id" type="hidden" > 
  19. <div class="panel">'; 
  20. $filter .= '<div class="panel-profile-header">'; 
  21. if(!empty($image)) {  
  22. $filter .= '<div class="image-upload-container">  
  23. <img class="img-profile-header-background" id="user-banner-image" style="width: 100%; position: relative; top:'.$pos.'px;" 
  24. src="'.$image.'" >  
  25. <div id="bpci-polaroid-upload-banner"> </div><div id="profile-mass">'.__("Drag cover", "bp-cover").'</div> </div> '; 
  26. }else{ 
  27. if(!empty($cover_profile)) { 
  28. $filter .= '<div class="image-upload-container"> 
  29. <div id="bpci-polaroid-upload-banner"> </div> 
  30. <img class="img-profile-header-background" id="user-banner-image" src="'. $cover_profile .'" width="100%"/></div> '; 
  31. }else{ 
  32. $filter .= '<div class="image-upload-container"> 
  33. <div id="bpci-polaroid-upload-banner"> </div> 
  34. <img class="img-profile-header-background" id="user-banner-image" src="'. BPCO_PLUGIN_URL .'/images/bg-profile.jpg " width="100%"/></div> '; 
  35.  
  36. $filter .= '<div class="img-profile-data"> 
  37. <h1>'.core_get_user_displayname_box( $user_id ).'</h1> 
  38. <h2>'.core_get_user_description_limit( $user_id ).'</h2> 
  39. </div>'; 
  40. if ($user_id == $author_id) { 
  41. $filter .= '<div style="display: none;" class="image-upload-buttons" id="banner-image-upload-buttons"> 
  42. <div class="uploadBox" id="bannerfileupload">'; 
  43.  
  44. foreach( $pics as $pic ) { 
  45. $attachment_id = isset($pic['meta_value']) ? (int)$pic['meta_value'] : 0; 
  46. $filter .='<a href="javascript:void(0)" id="uploadcover" class="btnc btn-info btn-sm" href=""><i class="fa fa-cloud-upload"></i></a>  
  47. <input type="file" name="cover_filename" id="cover_pic" class="uploadFile" >';  
  48.  
  49. if ( $attachment_id > 0 ) { 
  50. $filter .= '<a class="btnc btn-info btn-sm" href="#" data-modal-id="popup1"><i class="fa fa-pic"></i></a>'; 
  51. if(!empty($image)) { 
  52. $filter .='<a href="#" class="btnc btn-save btn-sm" ><i class="fa fa-save"></i></a> <a href="#" class="edit-cover btnc btn-info btn-sm" ><i class="fa fa-edit"></i></a><a href="#" class="btnc btn-remove btn-sm" ><i class="fa fa-remove"></i></a>'; 
  53. $filter .= ' </div></div>';  
  54. }  
  55. $filter .= '</div><div class="image-upload profile-user-photo-container ava" > 
  56. <div id="bpci-polaroid-upload-avatar"> </div>';  
  57. $filter .= $avatar ; 
  58. if ($user_id == $author_id) { 
  59. $filter .= '<div class="image-upload-buttons" id="profile-image-upload-buttons"> 
  60. <div class="uploadBox" id="profilefileupload">  
  61. <a href="javascript:void(0)" id="uploadavatar" class="btnc btn-info btn-sm" href=""> 
  62. <i class="fa fa-cloud-upload"></i></a> 
  63. <input type="file" name="avatar_filename" id="avatar_pic" class="uploadFile" >  
  64. </div>  
  65. </div>  
  66. <div id="item-meta"></div>';  
  67. $filter .= '</div></div>'; 
  68.  
  69. echo apply_filters( 'cover_image_scr', $filter);