Skip to:
Content
Pages
Categories
Search
Top
Bottom

Displaying cover image BuddyPress 2.4


  • Andrew
    Participant

    @sm60

    In Buddypress 2.4 beta there is a new (excellent) feature for members to display a header image:

    BuddyPress Cover Images

    By default it displays the header image by a CSS background_url. Does anyone have any idea of how to change it so it displays as an <img /> tag instead?

    I have my own custom template, and I only need to know what to put in the img tag src="" to display it. I have been trying to look through the new code related to the cover image to see if there is a function I can use in the img src="" to display the cover image but I don’t think there is one.

    Any help appreciated.

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

  • Andrew
    Participant

    @sm60

    * 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.


    danbp
    Moderator

    @danbp

    Please, read a possible answer in this new codex article:

    BuddyPress Cover Images


    Andrew
    Participant

    @sm60

    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


    r-a-y
    Keymaster

    @r-a-y

    Try:

    $cover_image_url = bp_attachments_get_attachment( 'url', array( 'item_id' => bp_displayed_user_id() ) );


    Andrew
    Participant

    @sm60

    Perfect. Just what I needed. Thanks @r-a-y.


    Andrew
    Participant

    @sm60

    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';
    }

    Andrew
    Participant

    @sm60

    Thanks @imaath And thanks for your involvement in the fantastic 2.4 release.

    yw @sm60 🙂

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Displaying cover image BuddyPress 2.4’ is closed to new replies.
Skip to toolbar