/**
 * Add inline css to display the component's single item cover image
 *
 * @since 2.4.0
 *
 * @param  bool $return True to get the inline css.
 * @return string|array the inline css or an associative array containing
 *                      the css rules and the style handle
 */
function bp_add_cover_image_inline_css($return = false)
{
    $bp = buddypress();
    // Find the component of the current item.
    if (bp_is_user()) {
        // User is not allowed to upload cover images
        // no need to carry on.
        if (bp_disable_cover_image_uploads()) {
            return;
        }
        $cover_image_object = array('component' => 'xprofile', 'object' => $bp->displayed_user);
    } elseif (bp_is_group()) {
        // Users are not allowed to upload cover images for their groups
        // no need to carry on.
        if (bp_disable_group_cover_image_uploads()) {
            return;
        }
        $cover_image_object = array('component' => 'groups', 'object' => $bp->groups->current_group);
    } else {
        $cover_image_object = apply_filters('bp_current_cover_image_object_inline_css', array());
    }
    // Bail if no component were found.
    if (empty($cover_image_object['component']) || empty($cover_image_object['object']) || !bp_is_active($cover_image_object['component'], 'cover_image')) {
        return;
    }
    // Get the settings of the cover image feature for the current component.
    $params = bp_attachments_get_cover_image_settings($cover_image_object['component']);
    // Bail if no params.
    if (empty($params)) {
        return;
    }
    // Try to call the callback.
    if (is_callable($params['callback'])) {
        $object_dir = $cover_image_object['component'];
        if ('xprofile' === $object_dir) {
            $object_dir = 'members';
        }
        $cover_image = bp_attachments_get_attachment('url', array('object_dir' => $object_dir, 'item_id' => $cover_image_object['object']->id));
        if (empty($cover_image)) {
            if (!empty($params['default_cover'])) {
                $cover_image = $params['default_cover'];
            }
        }
        $inline_css = call_user_func_array($params['callback'], array(array('cover_image' => esc_url_raw($cover_image), 'component' => sanitize_key($cover_image_object['component']), 'object_id' => (int) $cover_image_object['object']->id, 'width' => (int) $params['width'], 'height' => (int) $params['height'])));
        // Finally add the inline css to the handle.
        if (!empty($inline_css)) {
            // Used to get the css when Ajax setting the cover image.
            if (true === $return) {
                return array('css_rules' => '<style type="text/css">' . "\n" . $inline_css . "\n" . '</style>', 'handle' => $params['theme_handle']);
            }
            wp_add_inline_style($params['theme_handle'], $inline_css);
        } else {
            return false;
        }
    }
}
/**
 * Does the group has a cover image ?
 *
 * @since  2.4.0
 *
 * @param  int $group_id
 * @return bool True if the group has a cover image, false otherwise
 */
function bp_attachments_get_group_has_cover_image($group_id = 0)
{
    if (empty($group_id)) {
        $group_id = bp_get_current_group_id();
    }
    $cover_src = bp_attachments_get_attachment('url', array('object_dir' => 'groups', 'item_id' => $group_id));
    return (bool) apply_filters('bp_attachments_get_user_has_cover_image', $cover_src, $group_id);
}
Exemple #3
0
 function musik_before_group_header()
 {
     $cover = bp_attachments_get_attachment('url', array('object_dir' => 'groups', 'item_id' => bp_get_group_id()));
     echo sprintf('<style>#buddypress #header-cover-image { background-image: url(%s);}</style>', $cover);
 }
/**
 * Add the user's cover image to his embed profile
 *
 * @since  2.3.0
 */
function wp_idea_stream_buddypress_embed_inline_style()
{
    // Get displayed user id.
    $user_id = wp_idea_stream_users_displayed_user_id();
    // If not set, we're not on a user's profile.
    if (empty($user_id) || bp_disable_cover_image_uploads()) {
        return;
    }
    $cover_image = bp_attachments_get_attachment('url', array('object_dir' => 'members', 'item_id' => $user_id));
    if (!$cover_image) {
        return;
    }
    wp_add_inline_style('wp-idea-stream-embed-style', '
		#buddypress-cover-image {
			display: block;
			background-image: url(' . $cover_image . ');
			background-position: center top;
			background-repeat: no-repeat;
			background-size: cover;
			height: 100px;
			position: absolute;
			top: 0;
			left: 0;
			width: 100%;
			z-index: 1;
		}

		#wp-idea-stream .profile-header {
			z-index: 1;
			position: relative;
		}

		#wp-idea-stream .wp-embed-excerpt {
			margin-top: 1em;
		}

		#wp-idea-stream .profile-header .wp-embed-heading a {
			color: #FFF;
			text-rendering: optimizelegibility;
			text-shadow: 0px 0px 3px rgba( 0, 0, 0, 0.8 );
			height: 50px;
			line-height: 50px;
		}

		#wp-idea-stream .profile-header .user-avatar img.avatar {
			border: solid 2px #FFF;
			background: rgba( 255, 255, 255, 0.8 );
		}
	');
}
Exemple #5
0
    //No photo set? Show default + message
    if (empty($cover_image_url)) {
        $cover_image_url = WEFOSTER_DEFAULT_MEMBER_COVER_PHOTO;
        if (bp_is_my_profile()) {
            $link = bp_loggedin_user_domain() . $bp->profile->slug . 'profile/change-cover-image/';
            $text = esc_html__('Upload Your Cover Photo', 'wefoster');
            $action = '<div class="cover-photo-action vertical-center site-description my-profile"><a data-toggle="tooltip" data-placement="right" title="' . $text . '" data-container="body" href=' . $link . '><i class="fa fa-camera-retro"></i></a></div>';
        } else {
            $action = '';
        }
    }
    //
    //Group Cover Photos
    //
} else {
    $cover_image_url = bp_attachments_get_attachment('url', array('object_dir' => 'groups', 'item_id' => bp_get_current_group_id()));
    // is the current user a Group Admin? Allow the user to change.
    if (groups_is_user_admin(bp_loggedin_user_id(), bp_get_current_group_id())) {
        $link = bp_get_group_permalink(buddypress()->groups->current_group) . 'admin/group-cover-image/';
        $text = esc_html__('Change Group Cover Photo', 'wefoster');
        $action = '<div class="cover-photo-action vertical-center site-description my-profile"><a data-toggle="tooltip" data-placement="right" title="' . $text . '" data-container="body" href=' . $link . '><i class="fa fa-camera-retro"></i></a></div>';
    } else {
        $action = '';
    }
    //No photo set? Show default image + change upload message
    if (empty($cover_image_url)) {
        $cover_image_url = WEFOSTER_DEFAULT_GROUP_COVER_PHOTO;
        if (groups_is_user_admin(bp_loggedin_user_id(), bp_get_current_group_id())) {
            $link = bp_get_group_permalink(buddypress()->groups->current_group) . 'admin/group-cover-image/';
            $text = esc_html__('Upload Group Cover Photo', 'wefoster');
            $action = '<div class="cover-photo-action vertical-center site-description my-profile"><a data-toggle="tooltip" data-placement="right" title="' . $text . '" data-container="body" href=' . $link . '><i class="fa fa-camera-retro"></i></a></div>';