File tree Expand file tree Collapse file tree 4 files changed +28
-2
lines changed
Expand file tree Collapse file tree 4 files changed +28
-2
lines changed Original file line number Diff line number Diff line change 1+ Significance: patch
2+ Type: fixed
3+
4+ Follow-Me blocks now show the correct avatar on attachment pages.
Original file line number Diff line number Diff line change @@ -173,7 +173,7 @@ public function get_preferred_username() {
173173 */
174174 public function get_icon () {
175175 $ icon = \get_user_option ( 'activitypub_icon ' , $ this ->_id );
176- if ( wp_attachment_is_image ( $ icon ) ) {
176+ if ( false !== $ icon && wp_attachment_is_image ( $ icon ) ) {
177177 return array (
178178 'type ' => 'Image ' ,
179179 'url ' => esc_url ( wp_get_attachment_url ( $ icon ) ),
Original file line number Diff line number Diff line change @@ -78,7 +78,7 @@ public function test_account_with_invalid_user() {
7878 */
7979 public function test_account_with_invalid_target () {
8080 $ from = Actors::get_by_id ( self ::$ user_id )->get_id ();
81- $ to = 'https://invalid-url .com/user/1 ' ;
81+ $ to = 'https://example .com/user/1 ' ;
8282
8383 $ filter = function () {
8484 return new \WP_Error ( 'http_request_failed ' , 'Invalid URL ' );
Original file line number Diff line number Diff line change @@ -48,4 +48,26 @@ public function test_activitypub_cap() {
4848
4949 $ this ->assertTrue ( $ can );
5050 }
51+
52+ /**
53+ * Test that on attachment pages the user avatar is returned.
54+ *
55+ * @ticket https://github.com/Automattic/wordpress-activitypub/issues/1459
56+ * @covers ::get_icon
57+ */
58+ public function test_icon () {
59+ $ user_id = self ::factory ()->user ->create ( array ( 'role ' => 'author ' ) );
60+ $ user = User::from_wp_user ( $ user_id );
61+
62+ // Add attachment.
63+ $ attachment_id = self ::factory ()->attachment ->create_upload_object ( AP_TESTS_DIR . '/assets/test.jpg ' );
64+
65+ // Navigate to attachment page.
66+ $ this ->go_to ( get_attachment_link ( $ attachment_id ) );
67+
68+ $ icon = $ user ->get_icon ();
69+
70+ $ this ->assertArrayHasKey ( 'url ' , $ icon );
71+ $ this ->assertNotSame ( wp_get_attachment_url ( $ attachment_id ), $ icon ['url ' ] );
72+ }
5173}
You can’t perform that action at this time.
0 commit comments