Changeset 10754
- Timestamp:
- 05/14/2016 04:48:29 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/bp-core-avatars.php
r10721 r10754 1866 1866 // Use the local default image. 1867 1867 } elseif ( 'local' === $type ) { 1868 $avatar = buddypress()->plugin_url . 'bp-core/images/mystery-man.jpg'; 1868 $size = ''; 1869 if ( 1870 ( isset( $params['type'] ) && 'thumb' === $params['type'] && bp_core_avatar_thumb_width() <= 50 ) || 1871 ( isset( $params['width'] ) && $params['width'] <= 50 ) 1872 ) { 1873 1874 $size = '-50'; 1875 } 1876 1877 $avatar = buddypress()->plugin_url . "bp-core/images/mystery-man{$size}.jpg"; 1869 1878 1870 1879 // Use Gravatar's mystery person as fallback. 1871 1880 } else { 1872 $avatar = '//www.gravatar.com/avatar/00000000000000000000000000000000?d=mm&s=' . bp_core_avatar_full_width(); 1881 $size = ''; 1882 if ( isset( $params['type'] ) && 'thumb' === $params['type'] ) { 1883 $size = bp_core_avatar_thumb_width(); 1884 } else { 1885 $size = bp_core_avatar_full_width(); 1886 } 1887 $avatar = '//www.gravatar.com/avatar/00000000000000000000000000000000?d=mm&s=' . $size; 1873 1888 } 1874 1889 -
trunk/tests/phpunit/testcases/core/avatars.php
r10370 r10754 315 315 return $types; 316 316 } 317 318 /** 319 * @group BP7056 320 */ 321 public function test_no_grav_default_should_respect_thumb_type() { 322 $found = bp_core_fetch_avatar( array( 323 'item_id' => 12345, 324 'object' => 'user', 325 'type' => 'thumb', 326 'no_grav' => true, 327 'html' => false, 328 ) ); 329 330 $this->assertContains( 'mystery-man-50.jpg', $found ); 331 } 332 333 /** 334 * @group BP7056 335 */ 336 public function test_no_grav_default_should_return_thumb_avatar_for_small_enough_width() { 337 $found = bp_core_fetch_avatar( array( 338 'item_id' => 12345, 339 'object' => 'user', 340 'type' => 'full', 341 'width' => '50', 342 'no_grav' => true, 343 'html' => false, 344 ) ); 345 346 $this->assertContains( 'mystery-man-50.jpg', $found ); 347 } 348 349 /** 350 * @group BP7056 351 */ 352 public function test_no_grav_default_should_return_full_avatar_for_thumb_when_thumb_width_is_too_wide() { 353 add_filter( 'bp_core_avatar_thumb_width', array( $this, 'filter_thumb_width' ) ); 354 $found = bp_core_fetch_avatar( array( 355 'item_id' => 12345, 356 'object' => 'user', 357 'type' => 'thumb', 358 'no_grav' => true, 359 'html' => false, 360 ) ); 361 remove_filter( 'bp_core_avatar_thumb_width', array( $this, 'filter_thumb_width' ) ); 362 363 $this->assertContains( 'mystery-man.jpg', $found ); 364 } 365 366 public function filter_thumb_width() { 367 return 51; 368 } 317 369 }
Note: See TracChangeset
for help on using the changeset viewer.