Title: bp_attachments_get_src usues wrong function
Last modified: March 13, 2023

---

# bp_attachments_get_src usues wrong function

 *  Resolved [shawfactor](https://wordpress.org/support/users/shawfactor/)
 * (@shawfactor)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/bp_attachments_get_src-usues-wrong-function/)
 * bp_attachments_get_src() uses bp_upload_dir it should use bp_attachments_uploads_dir_get
   to consistent and allow for the fact that bp_attachments_uploads_dir_get can 
   be filtered.
 * This is a better approach
 *     ```wp-block-code
       function bp_attachments_get_src( $filename = '', $path = '' ) {
       	$src       = '';
       	//$uploads   = bp_upload_dir();
       	$uploads   = bp_attachments_uploads_dir_get();
       	$file_path = trailingslashit( $path ) . $filename;
   
       	if ( file_exists( $file_path ) && 0 === strpos( $file_path, WP_CONTENT_DIR ) ) {
       		$src = str_replace( $uploads['basedir'], $uploads['baseurl'], $file_path );
       	}
   
       	return $src;
       }
       ```
   
    -  This topic was modified 3 years, 2 months ago by [shawfactor](https://wordpress.org/support/users/shawfactor/).

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Author [Mathieu Viet](https://wordpress.org/support/users/imath/)
 * (@imath)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/bp_attachments_get_src-usues-wrong-function/#post-16555767)
 * Hi,
 * Thanks for your report. I’m going to look at it. You can follow progress about
   it here: [https://github.com/buddypress/bp-attachments/issues/60](https://github.com/buddypress/bp-attachments/issues/60)
 *  Thread Starter [shawfactor](https://wordpress.org/support/users/shawfactor/)
 * (@shawfactor)
 * [3 years, 1 month ago](https://wordpress.org/support/topic/bp_attachments_get_src-usues-wrong-function/#post-16570366)
 * Thankyou
 *  Plugin Author [Mathieu Viet](https://wordpress.org/support/users/imath/)
 * (@imath)
 * [3 years, 1 month ago](https://wordpress.org/support/topic/bp_attachments_get_src-usues-wrong-function/#post-16593204)
 * Fixed here: [https://github.com/buddypress/bp-attachments/commit/46cb2c59445d5b72886f3a4d6c8e37e72d680284](https://github.com/buddypress/bp-attachments/commit/46cb2c59445d5b72886f3a4d6c8e37e72d680284)
 *  Thread Starter [shawfactor](https://wordpress.org/support/users/shawfactor/)
 * (@shawfactor)
 * [3 years, 1 month ago](https://wordpress.org/support/topic/bp_attachments_get_src-usues-wrong-function/#post-16593248)
 * From memory there was one other place bp_upload_dir was used in the code. I’ve
   not looked at the impact (it may not be relevant) but probably worth investigating

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘bp_attachments_get_src usues wrong function’ is closed to new replies.

 * ![](https://ps.w.org/bp-attachments/assets/icon.svg?rev=2878763)
 * [BP Attachments](https://wordpress.org/plugins/bp-attachments/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/bp-attachments/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/bp-attachments/)
 * [Active Topics](https://wordpress.org/support/plugin/bp-attachments/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/bp-attachments/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/bp-attachments/reviews/)

 * 6 replies
 * 2 participants
 * Last reply from: [shawfactor](https://wordpress.org/support/users/shawfactor/)
 * Last activity: [3 years, 1 month ago](https://wordpress.org/support/topic/bp_attachments_get_src-usues-wrong-function/#post-16593248)
 * Status: resolved