Skip to:
Content

BuddyPress.org

Opened 3 weeks ago

Closed 3 days ago

#8150 closed defect (bug) (fixed)

Getting the blog avatar should be possible outside a blogs loop

Reported by: imath Owned by: imath
Milestone: 6.0.0 Priority: normal
Severity: normal Version: 2.4.0
Component: Blogs Keywords: has-patch commit
Cc:

Description (last modified by imath)

Testing the new Blog REST API Endpoints, I've noticed the prepare_item_for_response() method was missing the blog avatar.

Looking at the Blogs component, I've then noticed the bp_get_blog_avatar() function was requiring the $blogs_template global to be set to fetch the blog avatar, which makes it unusable by the BP REST API.

The attached patch makes it possible to get the blog avatar outside the Blogs loop.

Attachments (1)

8150.patch (8.9 KB) - added by imath 3 weeks ago.

Download all attachments as: .zip

Change History (10)

@imath
3 weeks ago

#1 @imath
3 weeks ago

  • Description modified (diff)

#2 @espellcaste
3 weeks ago

This is not the only Blog function that is attached to the blogs_template. I didn't add this because of this:

At the moment, blog avatars are simply the user avatars of the blog.

But I think it is an important change. :)

#3 @imath
3 weeks ago

Thanks for your feedback @espellcaste

It's a very good point about other functions. I'll also look at it.

This ticket was mentioned in Slack in #buddypress by espellcaste. View the logs.


2 weeks ago

#5 @espellcaste
6 days ago

@imath Just to confirm, did we decide to merge this one and update the other functions attachment from blogs_template?

#6 @imath
6 days ago

Just this one for 6.0.0 😊

#7 @espellcaste
3 days ago

k! This patch looks good! :)

#8 @imath
3 days ago

  • Keywords commit added

Nice, thanks for your feedback let's have it in!

#9 @imath
3 days ago

  • Owner set to imath
  • Resolution set to fixed
  • Status changed from new to closed

In 12496:

Make it possible to fetch a blog's avatar outside of the blogs loop

Passing 2 new parameters ($blog_id & $admin_user_id) to the bp_get_blog_avatar() function will return the corresponding blog's avatar without the need to run a blogs loop.

Props espellcaste

Fixes #8150

Note: See TracTickets for help on using tickets.