bp_media_upload()
Create and upload the media file
Description
Return
(array|null|WP_Error|WP_Post)
Source
File: bp-media/bp-media-functions.php
function bp_media_upload() { /** * Make sure user is logged in */ if ( ! is_user_logged_in() ) { return new WP_Error( 'not_logged_in', __( 'Please login in order to upload file media.', 'buddyboss' ), array( 'status' => 500 ) ); } $attachment = bp_media_upload_handler(); if ( is_wp_error( $attachment ) ) { return $attachment; } $name = $attachment->post_title; $thumb_nfo = wp_get_attachment_image_src( $attachment->ID ); $url_nfo = wp_get_attachment_image_src( $attachment->ID, 'full' ); $url = is_array( $url_nfo ) && ! empty( $url_nfo ) ? $url_nfo[0] : null; $thumb_nfo = is_array( $thumb_nfo ) && ! empty( $thumb_nfo ) ? $thumb_nfo[0] : null; $result = array( 'id' => (int) $attachment->ID, 'thumb' => esc_url( $thumb_nfo ), 'url' => esc_url( $url ), 'name' => esc_attr( $name ) ); return $result; }
Changelog
Version | Description |
---|---|
BuddyBoss 1.0.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.