* I meant to say CSS background-image: url()
instead of background_url.
Is it possible to change this to an <img>
tag instead? I just need to know what to put in the img src=""
to display the member’s cover image.
Thanks in advance.
Please, read a possible answer in this new codex article:
BuddyPress Cover Images
I can set the size and default image from that article, but I’m still not sure how to display it in an img tag.
With the WordPress header image, you can display the admin header image in an img tag:
<img src="<?php header_image(); ?>" />
Is there a Buddypress equivalent for the WordPress function header_image()
?
https://codex.wordpress.org/Function_Reference/header_image
Try:
$cover_image_url = bp_attachments_get_attachment( 'url', array( 'item_id' => bp_displayed_user_id() ) );
Perfect. Just what I needed. Thanks @r-a-y.
Just one quick thing. Is it possible to set this up so the default cover image works?
$cover_image_url = bp_attachments_get_attachment( 'url', array( 'item_id' => bp_displayed_user_id() ) );
doesn’t work for the default cover image:
function your_theme_xprofile_cover_image( $settings = array() ) {
$settings['width'] = 1000;
$settings['height'] = 333;
$settings['default_cover'] = 'http://mysite/link-to-default-coverimage.jpg';
return $settings;
}
add_filter( 'bp_before_xprofile_cover_image_settings_parse_args', 'your_theme_xprofile_cover_image', 10, 1 );
add_filter( 'bp_before_groups_cover_image_settings_parse_args', 'your_theme_xprofile_cover_image', 10, 1 );
You can do it without the cover image settings.
if ( ! $cover_image_url ) {
$cover_image_url = 'http://mysite/link-to-default-coverimage.jpg';
}
Thanks @imaath And thanks for your involvement in the fantastic 2.4 release.