BP_REST_Attachments_Group_Avatar_Endpoint::get_item( WP_REST_Request $request )
Fetch an existing group avatar.
Description
Parameters
- $request
-
(Required) Full details about the request.
Return
(WP_REST_Response) | WP_Error
Source
File: bp-groups/classes/class-bp-rest-attachments-group-avatar-endpoint.php
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | public function get_item( $request ) { $args = array (); foreach ( array ( 'full' , 'thumb' ) as $type ) { $args [ $type ] = bp_core_fetch_avatar( array ( 'object' => $this ->object, 'type' => $type , 'item_id' => (int) $this ->group->id, 'html' => (bool) $request [ 'html' ], 'alt' => $request [ 'alt' ], ) ); } // Get the avatar object. $avatar = $this ->get_avatar_object( $args ); if ( ! $avatar ->full && ! $avatar ->thumb ) { return new WP_Error( 'bp_rest_attachments_group_avatar_no_image' , __( 'Sorry, there was a problem fetching this group avatar.' , 'buddyboss' ), array ( 'status' => 500, ) ); } $retval = $this ->prepare_response_for_collection( $this ->prepare_item_for_response( $avatar , $request ) ); $response = rest_ensure_response( $retval ); /** * Fires after a group avatar is fetched via the REST API. * * @param string $avatar The group avatar. * @param WP_REST_Response $response The response data. * @param WP_REST_Request $request The request sent to the API. * * @since 0.1.0 */ do_action( 'bp_rest_attachments_group_avatar_get_item' , $avatar , $response , $request ); return $response ; } |
Changelog
Version | Description |
---|---|
0.1.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.