i @m1000,
try this (add to bp-custom.php):
function bpex_cover_img_path() {
// Is the current page a user page?
if ( bp_is_user() ) {
$user_id = bp_displayed_user_id();
$attachment = bp_attachments_get_attachment( 'url', array( 'item_id' => $user_id ) );
$image_path = $attachment;
// output only if an attachment exist
if( !empty( $attachment ) ):
echo 'Cover image path: <code>'. $image_path .'</code>';
endif;
}
}
add_action( 'bp_profile_header_meta', 'bpex_cover_img_path' );
You’re welcome. Can i ask why do you wanted this ? What is the purpose to show this link publicly ? By default, it is only used inside the background img css.
I just what to use it inside img tag.
BTW, why this code doesn’t work for groups?
function bp_cover_group_img_path() {
// Is the current page a user page?
if ( bp_is_group() ) {
$group_id = bp_get_group_id();
$attachment = bp_attachments_get_attachment( 'url', array( 'item_id' => $group_id ) );
$image_path = $attachment;
// output only if an attachment exist
if( !empty( $attachment ) ):
echo $image_path;
endif;
}
}
add_action( 'bp_group_cover_path', 'bp_cover_group_img_path' );
You need to specify the object.
$attachment = bp_attachments_get_attachment( 'url', array(
'object_dir' => 'groups',
'item_id' => $group_id,
) );
Reference
bp_attachments_get_attachment