Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
10/30/2020 10:13:38 PM (4 months ago)
Author:
imath
Message:

Blogs: use a default "blavatar" when the blog has no site icon

So far when the Blogs component was not supporting the WordPress site icon feature or when the blog had no site icon set, we used to fallback on the Blog Administrator's avatar.

We realized this was a wrong approach, because:

  • the site creator may no longer be a member of the specific site, in which case the lowest id will belong to a different (non-admin) user.
  • The site admin may have changed in some other way.
  • The site creator's account may have been deleted.
  • Etc.

When any of these happen, you get the avatar of a random site user.

That's why just like we do for users or groups, we are now using a default blog avatar (mysterious-blog.png) as a fallback when the site icon for the blog is not available.

Props boonebgorges, vapvarun, johnjamesjacoby

Fixes #8179

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/blogs/template.php

    r12606 r12772  
    398398
    399399        $blogs_template = $reset_blogs_template;
    400 
    401         $this->assertTrue( $avatar === bp_core_fetch_avatar( array(
    402             'type'          => 'full',
    403             'item_id'       => $u,
    404             'alt'           => 'test',
    405             'no_grav'       => true,
    406             'class'         => 'avatar',
    407         ) ) );
     400        $expected       = bp_core_fetch_avatar(
     401            array(
     402                'type'    => 'full',
     403                'item_id' => $u,
     404                'alt'     => 'test',
     405                'no_grav' => true,
     406                'class'   => 'avatar',
     407            )
     408        );
     409
     410        $this->assertTrue( $avatar === $expected );
    408411    }
    409412
     
    445448    }
    446449
     450    /**
     451     * @group avatar
     452     * @group BP_Blogs_Template
     453     * @group bp_get_blog_avatar
     454     */
     455    public function test_bp_get_blog_default_avatar() {
     456        if ( ! is_multisite() ) {
     457            $this->markTestSkipped();
     458        }
     459
     460        global $blogs_template;
     461        $reset_blogs_template = $blogs_template;
     462        $blogs_template = null;
     463
     464        $u = self::factory()->user->create();
     465        $b = self::factory()->blog->create( array(
     466            'title' => 'The Foo Bar Blog',
     467            'user_id' => $u,
     468        ) );
     469
     470        $avatar = bp_get_blog_avatar(
     471            array(
     472                'type'    => 'thumb',
     473                'blog_id' => $b,
     474                'html'    => false,
     475            )
     476        );
     477
     478        $blogs_template = $reset_blogs_template;
     479        $expected       = buddypress()->plugin_url . "bp-core/images/mystery-blog-50.png";
     480
     481        $this->assertTrue( $avatar === $expected );
     482    }
     483
    447484    public function filter_blog_avatar() {
    448485        return BP_TESTS_DIR . 'assets/upside-down.jpg';
Note: See TracChangeset for help on using the changeset viewer.