Skip to:
Content
Pages
Categories
Search
Top
Bottom

cover image not show


  • emilia015
    Participant

    @emilia015

    Hi, I’m trying to show cover image in activity

    here code original

    // Register the Cover Image feature for Users profiles
    function bp_default_register_feature() {
        /**
         * You can choose to register it for Members and / or Groups by including (or not) 
         * the corresponding components in your feature's settings. In this example, we
         * chose to register it for both components.
         */
        $components = array( 'groups', 'xprofile');
     
        // Define the feature's settings
        $cover_image_settings = array(
            'name'     => 'cover_image', // feature name
            'settings' => array(
                'components'   => $components,
                'width'        => 940,
                'height'       => 225,
                'callback'     => 'bp_default_cover_image',
                'theme_handle' => 'bp-default-main',
            ),
        );
     
     
        // Register the feature for your theme according to the defined settings.
        bp_set_theme_compat_feature( bp_get_theme_compat_id(), $cover_image_settings );
    }
    add_action( 'bp_after_setup_theme', 'bp_default_register_feature' );

    here my code

    /**
     * Your theme callback function
     *
     * <a class="bp-suggestions-mention" href="https://buddypress.org/members/see/" rel="nofollow">@see</a> bp_legacy_theme_cover_image() to discover the one used by BP Legacy
     */
    function your_theme_cover_image_callback( $params = array() ) {
        if ( empty( $params ) ) {
            return;
        }
     
        return '
            /* Cover image - Do not forget this part */
            #buddypress #header-cover-image {
                height: ' . $params["height"] . 'px;
                background-image: url(' . $params['cover_image'] . ');
            }
        ';
    }
    add_filter( 'bp_before_xprofile_cover_image_settings_parse_args', 'your_theme_cover_image_css', 10, 1 );
    add_filter( 'bp_before_groups_cover_image_settings_parse_args', 'your_theme_cover_image_css', 10, 1 );
    add_filter( 'bp_before_members_cover_image_settings_parse_args', 'your_theme_cover_image_css', 10, 1 );
    add_filter( 'bp_before_activity_cover_image_settings_parse_args', 'your_theme_cover_image_css', 10, 1 ); 
    
    function your_theme_cover_image_css( $settings = array() ) {
        /**
         * If you are using a child theme, use bp-child-css
         * as the theme handel
         */
        $theme_handle = 'bp-parent-css';
     
        $settings['theme_handle'] = $theme_handle;
     
        /**
         * Then you'll probably also need to use your own callback function
         * <a class="bp-suggestions-mention" href="https://buddypress.org/members/see/" rel="nofollow">@see</a> the previous snippet
         */
         $settings['callback'] = 'your_theme_cover_image_callback';
         
     
        return $settings;
    }
    add_filter( 'bp_before_xprofile_cover_image_settings_parse_args', 'your_theme_cover_image_css', 10, 1 );
    add_filter( 'bp_before_groups_cover_image_settings_parse_args', 'your_theme_cover_image_css', 10, 1 );
    add_filter( 'bp_before_members_cover_image_settings_parse_args', 'your_theme_cover_image_css', 10, 1 );
    add_filter( 'bp_before_activity_cover_image_settings_parse_args', 'your_theme_cover_image_css', 10, 1 );
    
    // Register the Cover Image feature for Users profiles
    function bp_default_register_feature() {
        /**
         * You can choose to register it for Members and / or Groups by including (or not) 
         * the corresponding components in your feature's settings. In this example, we
         * chose to register it for both components.
         */
        $components = array( 'groups', 'members', 'xprofile', 'activity');
     
        // Define the feature's settings
        $cover_image_settings = array(
            'name'     => 'cover_image', // feature name
            'settings' => array(
                'components'   => $components,
                'width'        => 940,
                'height'       => 225,
                'callback'     => 'bp_default_cover_image',
                'theme_handle' => 'bp-default-main',
            ),
        );
     
     
        // Register the feature for your theme according to the defined settings.
        bp_set_theme_compat_feature( bp_get_theme_compat_id(), $cover_image_settings );
    }
    add_action( 'bp_after_setup_theme', 'bp_default_register_feature' );
    
    // Example of function to customize the display of the cover image
    function bp_default_cover_image( $params = array() ) {
        if ( empty( $params ) ) {
            return;
        }
     
        // The complete css rules are available here: https://gist.github.com/imath/7e936507857db56fa8da#file-bp-default-patch-L34
        return '
            /* Cover image */
            #header-cover-image {
                display: block;
                height: ' . $params["height"] . 'px;
                background-image: url(' . $params['cover_image'] . ');
            }
        ';
    }
    

    I added the components: Members und activity but did not show the image cover in activity und member. Only load the css to show cover image in groups and profile.

    thank you very much for your help…

  • You must be logged in to reply to this topic.
Skip to toolbar