bp_media_download_file( $attachment_id,  $type = 'media' )

Description

Source

File: bp-templates/bp-nouveau/includes/media/functions.php

211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
function bp_media_download_file( $attachment_id, $type = 'media' ) {
 
    // Add action to prevent issues in IE.
    add_action( 'nocache_headers', 'bp_media_ie_nocache_headers_fix' );
 
    if ( 'media' === $type ) {
 
        $the_file = wp_get_attachment_url( $attachment_id );
 
        if ( ! $the_file ) {
            return;
        }
 
        // clean the file url.
        $file_url = stripslashes( trim( $the_file ) );
 
        // get filename.
        $file_name = basename( $the_file );
 
        bp_media_download_file_force( $the_file, $file_name );
    }
 
}

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.