Skip to content

Commit a91c1c2

Browse files
mattwiebepfefferle
andauthored
Add default blog user icon (#412)
* add a default WP icon for the blog user --------- Co-authored-by: Matthias Pfefferle <[email protected]>
1 parent 2705172 commit a91c1c2

File tree

5 files changed

+18
-6
lines changed

5 files changed

+18
-6
lines changed

assets/img/mp.jpg

1.97 KB
Loading

assets/img/wp-logo.png

11.6 KB
Loading

build/follow-me/style-index.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

includes/model/class-blog-user.php

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,23 +122,34 @@ public function get_preferred_username() {
122122
/**
123123
* Get the User-Icon.
124124
*
125-
* @return array|null The User-Icon.
125+
* @return array The User-Icon.
126126
*/
127127
public function get_icon() {
128128
// try site icon first
129129
$icon_id = get_option( 'site_icon' );
130+
130131
// try custom logo second
131132
if ( ! $icon_id ) {
132133
$icon_id = get_theme_mod( 'custom_logo' );
133134
}
134-
if ( ! $icon_id ) {
135-
return null;
135+
136+
$icon_url = false;
137+
138+
if ( $icon_id ) {
139+
$icon = wp_get_attachment_image_src( $icon_id, 'full' );
140+
if ( $icon ) {
141+
$icon_url = $icon[0];
142+
}
143+
}
144+
145+
if ( ! $icon_url ) {
146+
// fallback to default icon
147+
$icon_url = plugins_url( '/assets/img/wp-logo.png', ACTIVITYPUB_PLUGIN_FILE );
136148
}
137149

138-
$image = wp_get_attachment_image_src( $icon_id, 'full' );
139150
return array(
140151
'type' => 'Image',
141-
'url' => esc_url( $image[0] ),
152+
'url' => esc_url( $icon_url ),
142153
);
143154
}
144155

src/follow-me/style.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
height: 75px;
99
width: 75px;
1010
margin-right: 1rem;
11+
border-radius: 50%;
1112
}
1213
.activitypub-profile__name {
1314
margin: 0;

0 commit comments

Comments
 (0)