本文整理汇总了PHP中bp_core_avatar_default函数的典型用法代码示例。如果您正苦于以下问题:PHP bp_core_avatar_default函数的具体用法?PHP bp_core_avatar_default怎么用?PHP bp_core_avatar_default使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bp_core_avatar_default函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: userpro_user_has_avatar
/**
* Check if the given user has an uploaded avatar
* @return boolean
*/
function userpro_user_has_avatar($user_id = false)
{
// $user_id = bp_loggedin_user_id();
if (bp_core_fetch_avatar(array('item_id' => $user_id, 'no_grav' => true, 'html' => false)) != bp_core_avatar_default()) {
return true;
}
return false;
}
示例2: bp_get_group_has_avatar
function bp_get_group_has_avatar($group_id = false)
{
global $bp;
if (false === $group_id) {
$group_id = bp_get_current_group_id();
}
// Todo - this looks like an overgeneral check
if (!empty($_FILES)) {
return false;
}
$group_avatar = bp_core_fetch_avatar(array('item_id' => $group_id, 'object' => 'group', 'no_grav' => true, 'html' => false));
if (bp_core_avatar_default('local') === $group_avatar) {
return false;
}
return true;
}
示例3: bp_get_user_has_avatar
/**
* Check if a given user ID has an uploaded avatar.
*
* @since 1.0.0
*
* @param int $user_id ID of the user whose avatar is being checked.
*
* @return bool True if the user has uploaded a local avatar. Otherwise false.
*/
function bp_get_user_has_avatar($user_id = 0)
{
if (empty($user_id)) {
$user_id = bp_displayed_user_id();
}
$retval = false;
if (bp_core_fetch_avatar(array('item_id' => $user_id, 'no_grav' => true, 'html' => false)) != bp_core_avatar_default('local')) {
$retval = true;
}
/**
* Filters whether or not a user has an uploaded avatar.
*
* @since 1.6.0
*
* @param bool $retval Whether or not a user has an uploaded avatar.
* @param int $user_id ID of the user being checked.
*/
return (bool) apply_filters('bp_get_user_has_avatar', $retval, $user_id);
}
示例4: bp_get_group_has_avatar
/**
* Return whether a group has an avatar.
*
* @since 1.1.0
*
* @param int|bool $group_id Group ID to check.
* @return boolean
*/
function bp_get_group_has_avatar($group_id = false)
{
if (false === $group_id) {
$group_id = bp_get_current_group_id();
}
$group_avatar = bp_core_fetch_avatar(array('item_id' => $group_id, 'object' => 'group', 'no_grav' => true, 'html' => false));
if (bp_core_avatar_default('local') === $group_avatar) {
return false;
}
return true;
}
示例5: bp_get_user_has_avatar
/**
* Check if a given user ID has an uploaded avatar.
*
* @since BuddyPress (1.0.0)
*
* @param int $user_id ID of the user whose avatar is being checked.
* @return bool True if the user has uploaded a local avatar. Otherwise false.
*/
function bp_get_user_has_avatar($user_id = 0)
{
if (empty($user_id)) {
$user_id = bp_displayed_user_id();
}
$retval = false;
if (bp_core_fetch_avatar(array('item_id' => $user_id, 'no_grav' => true, 'html' => false)) != bp_core_avatar_default('local')) {
$retval = true;
}
return (bool) apply_filters('bp_get_user_has_avatar', $retval, $user_id);
}
示例6: rtmedia_author_profile_pic
function rtmedia_author_profile_pic($show_link = true, $echo = true, $author_id = false)
{
global $rtmedia_backbone;
if ($rtmedia_backbone['backbone']) {
echo '';
} else {
if (!$author_id || $author_id == "") {
global $rtmedia_media;
$author_id = $rtmedia_media->media_author;
}
$show_link = apply_filters("rtmedia_single_media_show_profile_picture_link", $show_link);
$profile_pic = "";
if ($show_link) {
$profile_pic .= "<a href='" . get_rtmedia_user_link($author_id) . "' title='" . rtmedia_get_author_name($author_id) . "'>";
}
$size = apply_filters("rtmedia_single_media_profile_picture_size", 90);
if (function_exists("bp_get_user_has_avatar")) {
if (bp_core_fetch_avatar(array('item_id' => $author_id, 'object' => 'user', 'no_grav' => false, 'html' => false)) != bp_core_avatar_default()) {
$profile_pic .= bp_core_fetch_avatar(array('item_id' => $author_id, 'object' => 'user', 'no_grav' => false, 'html' => true, 'width' => $size, 'height' => $size));
} else {
$profile_pic .= "<img src='" . bp_core_avatar_default() . "' width='" . $size . "' height='" . $size . "'/>";
}
} else {
$profile_pic .= get_avatar($author_id, $size);
}
if ($show_link) {
$profile_pic .= "</a>";
}
if ($echo) {
echo $profile_pic;
} else {
return $profile_pic;
}
}
}
示例7: bp_core_fetch_avatar_url
/**
* Filters a locally uploaded avatar URL.
*
* @since BuddyPress (1.2.5)
*
* @param string $avatar_url URL for a locally uploaded avatar.
* @param array $params Array of parameters for the request.
*
* @return string|void
*/
public function bp_core_fetch_avatar_url($avatar_url, $params)
{
$bp = buddypress();
// If avatars are disabled for the root site, obey that request and bail
if (!$bp->avatar->show_avatars) {
return;
}
// only for users
if ($params['object'] != 'user') {
return;
}
$fb_id = get_user_meta($params['item_id'], '_fb_user_id', true);
if (empty($fb_id)) {
return $avatar_url;
}
// If is not gravatar it's local. And if it's local but the not the default one it means it's one uploaded by user
// so we show that one.
if (!empty($avatar_url)) {
$gravatar = apply_filters('bp_gravatar_url', '//www.gravatar.com/avatar/');
if (strpos($avatar_url, $gravatar) === false && $avatar_url != bp_core_avatar_default('local')) {
return $avatar_url;
}
}
return 'https://graph.facebook.com/' . $fb_id . '/picture?width=' . $params['width'] . '&height=' . $params['height'];
}
示例8: bp_core_fetch_avatar_filter_check
public function bp_core_fetch_avatar_filter_check($html, $params)
{
// Check that the passed parameters match the original custom parameters.
$this->assertEmpty(array_merge(array_diff($params, $this->params), array_diff($this->params, $params)));
// Check the returned html to see that it matches an expected value.
// Get the correct default avatar, based on whether gravatars are allowed.
if ($params['no_grav']) {
$avatar_url = bp_core_avatar_default('local');
} else {
// This test has the slight odor of hokum since it recreates so much code that could be changed at any time.
$bp = buddypress();
$host = '//www.gravatar.com/avatar/';
// Set expected gravatar type
if (empty($bp->grav_default->{$this->params['object']})) {
$default_grav = 'wavatar';
} elseif ('mystery' == $bp->grav_default->{$this->params['object']}) {
$default_grav = apply_filters('bp_core_mysteryman_src', 'mm', $this->params['width']);
} else {
$default_grav = $bp->grav_default->{$this->params['object']};
}
$avatar_url = $host . md5(strtolower($this->params['email'])) . '?d=' . $default_grav . '&s=' . $this->params['width'];
// Gravatar rating; http://bit.ly/89QxZA
$rating = get_option('avatar_rating');
if (!empty($rating)) {
$avatar_url .= "&r={$rating}";
}
}
$expected_html = '<img src="' . $avatar_url . '" id="' . $this->params['css_id'] . '" class="' . $this->params['class'] . ' ' . $this->params['object'] . '-' . $this->params['item_id'] . '-avatar avatar-' . $this->params['width'] . ' photo" width="' . $this->params['width'] . '" height="' . $this->params['height'] . '" alt="' . $this->params['alt'] . '" title="' . $this->params['title'] . '" />';
$this->assertEquals($html, $expected_html);
}
示例9: bp_core_fetch_avatar
//.........这里部分代码省略.........
$avatar_files = array();
while (false !== ($avatar_file = readdir($av_dir))) {
// Only add files to the array (skip directories)
if (2 < strlen($avatar_file)) {
$avatar_files[] = $avatar_file;
}
}
// Check for array
if (0 < count($avatar_files)) {
// Check for current avatar
foreach ($avatar_files as $key => $value) {
if (strpos($value, $avatar_size) !== false) {
$avatar_url = $avatar_folder_url . '/' . $avatar_files[$key];
}
}
// Legacy avatar check
if (!isset($avatar_url)) {
foreach ($avatar_files as $key => $value) {
if (strpos($value, $legacy_user_avatar_name) !== false) {
$avatar_url = $avatar_folder_url . '/' . $avatar_files[$key];
}
}
// Legacy group avatar check
if (!isset($avatar_url)) {
foreach ($avatar_files as $key => $value) {
if (strpos($value, $legacy_group_avatar_name) !== false) {
$avatar_url = $avatar_folder_url . '/' . $avatar_files[$key];
}
}
}
}
}
}
// Close the avatar directory
closedir($av_dir);
// If we found a locally uploaded avatar
if (isset($avatar_url)) {
// Return it wrapped in an <img> element
if (true === $html) {
return apply_filters('bp_core_fetch_avatar', '<img src="' . $avatar_url . '" alt="' . esc_attr($alt) . '" class="' . esc_attr($class) . '"' . $css_id . $html_width . $html_height . $title . ' />', $params, $item_id, $avatar_dir, $css_id, $html_width, $html_height, $avatar_folder_url, $avatar_folder_dir);
// ...or only the URL
} else {
return apply_filters('bp_core_fetch_avatar_url', $avatar_url);
}
}
}
// If no avatars could be found, try to display a gravatar
// Skips gravatar check if $no_grav is passed
if (!apply_filters('bp_core_fetch_avatar_no_grav', $no_grav)) {
// Set gravatar size
if ($width) {
$grav_size = $width;
} else {
if ('full' == $type) {
$grav_size = bp_core_avatar_full_width();
} else {
if ('thumb' == $type) {
$grav_size = bp_core_avatar_thumb_width();
}
}
}
// Set gravatar type
if (empty($bp->grav_default->{$object})) {
$default_grav = 'wavatar';
} else {
if ('mystery' == $bp->grav_default->{$object}) {
$default_grav = apply_filters('bp_core_mysteryman_src', bp_core_avatar_default(), $grav_size);
} else {
$default_grav = $bp->grav_default->{$object};
}
}
// Set gravatar object
if (empty($email)) {
if ('user' == $object) {
$email = bp_core_get_user_email($item_id);
} else {
if ('group' == $object || 'blog' == $object) {
$email = "{$item_id}-{$object}@{bp_get_root_domain()}";
}
}
}
// Set host based on if using ssl
if (is_ssl()) {
$host = 'https://secure.gravatar.com/avatar/';
} else {
$host = 'http://www.gravatar.com/avatar/';
}
// Filter gravatar vars
$email = apply_filters('bp_core_gravatar_email', $email, $item_id, $object);
$gravatar = apply_filters('bp_gravatar_url', $host) . md5(strtolower($email)) . '?d=' . $default_grav . '&s=' . $grav_size;
} else {
// No avatar was found, and we've been told not to use a gravatar.
$gravatar = apply_filters("bp_core_default_avatar_{$object}", BP_PLUGIN_URL . '/bp-core/images/mystery-man.jpg', $params);
}
if (true === $html) {
return apply_filters('bp_core_fetch_avatar', '<img src="' . $gravatar . '" alt="' . esc_attr($alt) . '" class="' . esc_attr($class) . '"' . $css_id . $html_width . $html_height . $title . ' />', $params, $item_id, $avatar_dir, $css_id, $html_width, $html_height, $avatar_folder_url, $avatar_folder_dir);
} else {
return apply_filters('bp_core_fetch_avatar_url', $gravatar);
}
}
示例10: bp_core_fetch_avatar_filter_check
public function bp_core_fetch_avatar_filter_check($html, $params)
{
// Check that the passed parameters match the original custom parameters.
$this->assertEmpty(array_merge(array_diff($params, $this->params), array_diff($this->params, $params)));
// Check the returned html to see that it matches an expected value.
// Get the correct default avatar, based on whether gravatars are allowed.
if ($params['no_grav']) {
$avatar_url = bp_core_avatar_default('local', $params);
} else {
// This test has the slight odor of hokum since it recreates so much code that could be changed at any time.
$bp = buddypress();
$host = '//www.gravatar.com/avatar/';
// Set expected gravatar type
if (empty($bp->grav_default->{$this->params['object']})) {
$default_grav = 'wavatar';
} elseif ('mystery' == $bp->grav_default->{$this->params['object']}) {
$default_grav = apply_filters('bp_core_mysteryman_src', 'mm', $this->params['width']);
} else {
$default_grav = $bp->grav_default->{$this->params['object']};
}
$avatar_url = $host . md5(strtolower($this->params['email']));
// Main Gravatar URL args.
$url_args = array('s' => $this->params['width']);
// Force default.
if (!empty($this->params['force_default'])) {
$url_args['f'] = 'y';
}
// Gravatar rating; http://bit.ly/89QxZA
$rating = strtolower(get_option('avatar_rating'));
if (!empty($rating)) {
$url_args['r'] = $rating;
}
// Default avatar.
if ('gravatar_default' !== $default_grav) {
$url_args['d'] = $default_grav;
}
// Set up the Gravatar URL.
$avatar_url = esc_url(add_query_arg(rawurlencode_deep(array_filter($url_args)), $avatar_url));
}
$expected_html = '<img src="' . $avatar_url . '" id="' . $this->params['css_id'] . '" class="' . $this->params['class'] . ' ' . $this->params['object'] . '-' . $this->params['item_id'] . '-avatar avatar-' . $this->params['width'] . ' photo" width="' . $this->params['width'] . '" height="' . $this->params['height'] . '" alt="' . $this->params['alt'] . '" title="' . $this->params['title'] . '" ' . $this->params['extra_attr'] . ' />';
$this->assertEquals($html, $expected_html);
}
示例11: oa_social_login_custom_avatar
/**
* Hook to display custom avatars
*/
function oa_social_login_custom_avatar($avatar, $mixed, $size, $default, $alt = '')
{
//The social login settings
static $oa_social_login_avatars = null;
if (is_null($oa_social_login_avatars)) {
$oa_social_login_settings = get_option('oa_social_login_settings');
$oa_social_login_avatars = isset($oa_social_login_settings['plugin_show_avatars_in_comments']) ? $oa_social_login_settings['plugin_show_avatars_in_comments'] : 0;
}
//Check if social avatars are enabled
if (!empty($oa_social_login_avatars)) {
//Check if we have an user identifier
if (is_numeric($mixed) and $mixed > 0) {
$user_id = $mixed;
} elseif (is_string($mixed) and $user = get_user_by('email', $mixed)) {
$user_id = $user->ID;
} elseif (is_object($mixed) and property_exists($mixed, 'user_id') and is_numeric($mixed->user_id)) {
$user_id = $mixed->user_id;
} else {
$user_id = null;
}
//User found?
if (!empty($user_id)) {
//Override current avatar ?
$override_avatar = true;
//BuddyPress (Thumbnails in the default WordPress toolbar)
if (function_exists('bp_core_fetch_avatar') and function_exists('bp_core_avatar_default')) {
//Fetch the BuddyPress user avatar
$bp_user_avatar = bp_core_fetch_avatar(array('item_id' => $user_id, 'no_grav' => true, 'html' => false));
//Do not override if it's not the default avatar
if (!empty($bp_user_avatar) and $bp_user_avatar != bp_core_avatar_default()) {
//User has probably upladed an avatar
$override_avatar = false;
}
}
//Show avatar?
if ($override_avatar) {
//Read the avatar
$user_meta_thumbnail = get_user_meta($user_id, 'oa_social_login_user_thumbnail', true);
$user_meta_picture = get_user_meta($user_id, 'oa_social_login_user_picture', true);
//Use the picture if possible
if ($oa_social_login_avatars == 2) {
$user_picture = !empty($user_meta_picture) ? $user_meta_picture : $user_meta_thumbnail;
} else {
$user_picture = !empty($user_meta_thumbnail) ? $user_meta_thumbnail : $user_meta_picture;
}
//Avatar found?
if ($user_picture !== false and strlen(trim($user_picture)) > 0) {
return '<img alt="' . oa_social_login_esc_attr($alt) . '" src="' . $user_picture . '" class="avatar avatar-social-login avatar-' . $size . ' photo" height="' . $size . '" width="' . $size . '" />';
}
}
}
}
//Default
return $avatar;
}
示例12: rtmedia_author_profile_pic
/**
* Media author's profile pic
*
* @global array $rtmedia_backbone
* @global object $rtmedia_media
*
* @param bool $show_link
* @param bool $echo
* @param bool $author_id
*
* @return string
*/
function rtmedia_author_profile_pic($show_link = true, $echo = true, $author_id = false)
{
global $rtmedia_backbone;
if ($rtmedia_backbone['backbone']) {
echo '';
} else {
if (empty($author_id)) {
global $rtmedia_media;
$author_id = $rtmedia_media->media_author;
}
$show_link = apply_filters('rtmedia_single_media_show_profile_picture_link', $show_link);
$profile_pic = '';
if ($show_link) {
$profile_pic .= "<a href='" . esc_url(get_rtmedia_user_link($author_id)) . "' title='" . esc_attr(rtmedia_get_author_name($author_id)) . "'>";
}
$size = apply_filters('rtmedia_single_media_profile_picture_size', 90);
if (function_exists('bp_get_user_has_avatar')) {
if (bp_core_fetch_avatar(array('item_id' => $author_id, 'object' => 'user', 'no_grav' => false, 'html' => false)) !== bp_core_avatar_default()) {
$profile_pic .= bp_core_fetch_avatar(array('item_id' => $author_id, 'object' => 'user', 'no_grav' => false, 'html' => true, 'width' => $size, 'height' => $size));
} else {
$profile_pic .= "<img src='" . esc_url(bp_core_avatar_default()) . "' width='" . esc_attr($size) . "' height='" . esc_attr($size) . "' />";
}
} else {
$profile_pic .= get_avatar($author_id, $size);
}
if ($show_link) {
$profile_pic .= '</a>';
}
if ($echo) {
echo $profile_pic;
// @codingStandardsIgnoreLine
} else {
return $profile_pic;
}
}
// End if().
}