bp_get_blog_avatar (|字符串数组args美元''

找一个博客头像。

描述

目前,博客化身只是博客管理员的用户化身。过滤“bp_get_blog_avatar_”。美元blog_id定制。

另请参阅

参数

args美元

数组|字符串(可选)这里列出了参数,并解释了它们的默认值。有关参数的更多信息,请参见bp_core_fetch_avatar ()

  • “alt”
    (字符串)默认值:“网站作者[用户名]的头像”。
  • “类”
    (字符串)默认值:《阿凡达》。
  • “类型”
    (字符串)默认值:“满”。
  • “宽度”
    (int | bool)默认值:false。
  • “高度”
    (int | bool)默认值:false。
  • “id”
    (保龄球)目前未使用。
  • “no_grav”
    (保龄球)默认值:真的。

默认值:“

返回

(字符串)用户头像字符串。

文件:bp-blogs / bp-blogs-template.php

函数bp_get_blog_avatar($args = ") {global $blogs_template;@todo:我们还需要过滤这个吗?如果(!Buddypress ()->avatar->show_avatars){返回false;} $author_displayname = bp_core_get_user_displayname($blogs_template->blog->admin_user_id);//解析参数。$r = bp_parse_args($args, array('type' => 'full', 'width' => false, 'height' => false, 'class' => 'avatar', 'id' => false, 'alt' => sprintf(__('网站作者%s的个人照片','buddyboss'), esc_attr($author_displayname)), 'no_grav' => true,));//如果有,使用站点图标。《阿凡达》= "美元;如果(bp_is_active('blog ', 'site-icon') && function_exists('has_site_icon')) {$ site_icon = bp_blogs_get_blogmeta(bp_get_blog_id(), "site_icon_url_{$r['type']}"); // Never attempted to fetch site icon before; do it now! if ( '' === $site_icon ) { switch_to_blog( bp_get_blog_id() ); // Fetch the other size first. if ( 'full' === $r['type'] ) { $size = bp_core_avatar_thumb_width(); $save_size = 'thumb'; } else { $size = bp_core_avatar_full_width(); $save_size = 'full'; } $site_icon = get_site_icon_url( $size ); // Empty site icons get saved as integer 0. if ( empty( $site_icon ) ) { $site_icon = 0; } // Sync site icon for other size to blogmeta. bp_blogs_update_blogmeta( bp_get_blog_id(), "site_icon_url_{$save_size}", $site_icon ); // Now, fetch the size we want. if ( 0 !== $site_icon ) { $size = 'full' === $r['type'] ? bp_core_avatar_full_width() : bp_core_avatar_thumb_width(); $site_icon = get_site_icon_url( $size ); } // Sync site icon to blogmeta. bp_blogs_update_blogmeta( bp_get_blog_id(), "site_icon_url_{$r['type']}", $site_icon ); restore_current_blog(); } // We have a site icon. if ( ! is_numeric( $site_icon ) ) { if ( empty( $r['width'] ) && ! isset( $size ) ) { $size = 'full' === $r['type'] ? bp_core_avatar_full_width() : bp_core_avatar_thumb_width(); } else { $size = (int) $r['width']; } $avatar = sprintf( '%4$s', esc_url( $site_icon ), esc_attr( "{$r['class']} avatar-{$size}" ), esc_attr( $size ), sprintf( esc_attr__( 'Site icon for %s', 'buddyboss' ), bp_get_blog_name() ) ); } } // Fallback to user ID avatar. if ( '' === $avatar ) { $avatar = bp_core_fetch_avatar( array( 'item_id' => $blogs_template->blog->admin_user_id, // 'avatar_dir' => 'blog-avatars', // 'object' => 'blog', 'type' => $r['type'], 'alt' => $r['alt'], 'css_id' => $r['id'], 'class' => $r['class'], 'width' => $r['width'], 'height' => $r['height'] ) ); } /** * In future BuddyPress versions you will be able to set the avatar for a blog. * Right now you can use a filter with the ID of the blog to change it if you wish. * By default it will return the avatar for the primary blog admin. * * This filter is deprecated as of BuddyPress 1.5 and may be removed in a future version. * Use the 'bp_get_blog_avatar' filter instead. */ $avatar = apply_filters( 'bp_get_blog_avatar_' . $blogs_template->blog->blog_id, $avatar ); /** * Filters a blog's avatar. * * @since BuddyPress 1.5.0 * * @param string $avatar Formatted HTML  element, or raw avatar * URL based on $html arg. * @param int $blog_id ID of the blog whose avatar is being displayed. * @param array $r Array of arguments used when fetching avatar. */ return apply_filters( 'bp_get_blog_avatar', $avatar, $blogs_template->blog->blog_id, $r ); }

问题吗?

我们总是很乐意帮助您解决代码或其他问题!搜索我们的开发人员文档联络支持,或与我们联系销售团队