cover_group_image_scr

The BuddyPress cover cover group image scr function.

Description

cover_group_image_scr(); 

Usage

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

Defined (1)

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

/templates/default/theme.php  
  1. function cover_group_image_scr() { 
  2. global $bp, $groups_template, $wpdb;  
  3. $user_id=get_current_user_id();  
  4. $group_id=bp_get_current_group_id(); 
  5. $avatar_options = array (  
  6. 'item_id' => $group_id,  
  7. 'object' => 'group',  
  8. 'type' => 'full',  
  9. 'class' => 'ava-cover',  
  10. 'width' => 90,  
  11. 'height' => 90 
  12. ); 
  13.  
  14. $cover_group = get_option( 'bp_cover_group' ); 
  15. $cover=groups_get_groupmeta($group_id, 'bp_cover_group', true); 
  16. $pos=groups_get_groupmeta($group_id, 'bp_cover_group_position', true); 
  17. $avatar_group = bp_core_fetch_avatar( $avatar_options ); 
  18. $filter ='<input id="id" name="id" type="hidden" ><div id="gal"> 
  19. <nav class="galnav "><div class="group-cover">';  
  20. if ( empty( $group ) ) { 
  21. $group =& $groups_template->group; 
  22. $query = new BP_Group_Member_Query( array( 
  23. 'group_id' => $group->id,  
  24. 'group_role' => 'admin',  
  25. 'type' => 'first_joined',  
  26. ) ); 
  27. if ( ! empty( $query->results ) ) { 
  28. $group->admins = $query->results;  
  29. }  
  30. if(!empty($cover)) {  
  31. $filter .='<div class="cover "><img class="bp-cover-top" style="width: 100%; position: relative; top:'.$pos.'px;" src="'.$cover.'"/></div> 
  32. <div id="bpci-polaroid-upload-group"> </div><div id="profile-mass">'.__("Drag cover", "bp-cover").'</div>'; 
  33. }else{ 
  34. if(!empty($cover_group)) { 
  35. $filter .='<div class="cover"><img class="bp-cover-top" src="'. $cover_group .' "/></div>'; 
  36. }else{ 
  37. $filter .='<div class="cover"><img class="bp-cover-top" src="'. BPCO_PLUGIN_URL .'/images/bg-profile.jpg "/></div>'; 
  38. $filter .= '</div><li><input type="radio" name="btn" value="group-cover" checked="checked"/> 
  39. <label for="btn">'.$avatar_group .'</label> 
  40. <figure> '; 
  41. $filter .='<figcaption> 
  42. <div class="ava-group">'.$avatar_group .'</div> 
  43. <h4>'.cover_group_name().'</h4>  
  44. <nav role="navigation"> 
  45. <p>'.cover_group_description().'</p><ul>'; 
  46.  
  47. if ( ! empty( $group->admins ) ) {  
  48. foreach( (array) $group->admins as $admin ) { 
  49. $admin_link = bp_core_get_user_domain( $admin->user_id, $admin->user_nicename, $admin->user_login ); 
  50. $admin_ava = bp_core_fetch_avatar(  
  51. array(  
  52. 'item_id' => $admin->user_id,  
  53. 'email' => $admin->user_email ,  
  54. 'type' => 'full',  
  55. 'class' => 'ava-cover',  
  56. 'width' => 90,  
  57. 'height' => 90 ) ); 
  58. $filter .= ' <li><a href="'.$admin_link.'" class="entypo-dribbble">'.$admin_ava .'</a></li>'; 
  59. }  
  60. $filter .='</ul></nav></figcaption>';  
  61. $filter .= '</figure></li>'; 
  62. if (is_admin() || $bp->is_item_admin ) {  
  63. $filter .='<li><input type="radio" name="btn" value="upload-cover"/> 
  64. <label for="btn">'.$admin_ava .'</label> 
  65. <figure class="entypo-forward">';  
  66. $filter .='<figcaption> <nav role="navigation"><h2>'.__("Gallery Cover", "bp-cover").'</h2><ul class="gallery-cover">'; 
  67. $activity_table = $wpdb->prefix."bp_activity"; 
  68. $activity_meta_table = $wpdb->prefix."bp_activity_meta";  
  69. $sql = "SELECT a.*, am.meta_value FROM $activity_table a INNER JOIN $activity_meta_table am ON a.id = am.activity_id WHERE a.item_id = $group_id AND meta_key = 'all_bp_cover_group' ORDER BY a.date_recorded DESC";  
  70. $attachment_ids = $wpdb->get_results($sql, ARRAY_A); 
  71. foreach( $attachment_ids as $attachment_id ) { 
  72. $images = isset($attachment_id['meta_value']) ? (int)$attachment_id['meta_value'] : 0; 
  73. $attachment_new = get_post_meta($images, 'bp_cover_group_thumb', true); 
  74. $attachment_old = wp_get_attachment_image_src( $images , 'thumbnail');  
  75. $image = ! empty( $attachment_new ) ? $attachment_new : $attachment_old[0];  
  76. //$image = wp_get_attachment_image_src($images); 
  77. $activity_id = $attachment_id[ 'id' ]; 
  78.  
  79. if(!empty($image)) { 
  80. $filter.='<li ><div id="'.$activity_id.'">  
  81. <a href="#" class="delete-pic" title="'.__("Delete", "bp-cover").'" onclick="delete_pic_cover_group(\''.$activity_id.'\', \''.admin_url( 'admin-ajax.php' ).'\'); return false;"></a> 
  82. <a href="#" class="pics" title="'.__("Select", "bp-cover").'" onclick="select_cover_for_group(\''.$activity_id.'\', \''.admin_url( 'admin-ajax.php' ).'\'); return false;"> 
  83. <img class="cover-pics" src="'. $image.'" /></a></div></li>'; 
  84. if(empty($image)) {  
  85. $filter .=' <h4>'.__("Gallery empty", "bp-cover").'</h4>'; 
  86. $filter .= '<p>'.__("you can upload image for cover group", "bp-cover").'</p>';  
  87. $filter .='</ul><ul class="upload-cover">'; 
  88. $filter .='<div class="uploadBox" id="groupfileupload">'; 
  89.  
  90. $filter .=' <a href="javascript:void(0)" id="uploadgroup" class="btnc btn-info btn-sm" href=""><i class="fa fa-cloud-upload"></i> </a> 
  91. <input type="file" name="group_filename" id="group_pic" class="uploadFile" > ';  
  92. $filter .= '<a href="#" class="edit-cover btnc btn-info btn-sm" ><i class="fa fa-edit "></i></a> 
  93. <a href="#" class="btnc btn-save btn-sm" ><i class="fa fa-save"></i></a></div></ul></nav></figcaption></figure></li> ' ; 
  94.  
  95. $filter .='</nav></div>';  
  96.  
  97.  
  98. echo apply_filters( 'cover_group_image_scr', $filter);