How to Add Custom Author Photos to WordPress Without Gravatar
WordPress normally uses Gravatar to display profile photos for post authors and commenters. While this works for many websites, it also means that each author needs a Gravatar account connected to the email address used on your website.
If you prefer to manage author photos directly inside WordPress, you can add a custom photo uploader to each user’s profile. The uploaded image can then appear automatically in the author box and beside the author’s name at the top of every article.
If an author has not uploaded a photo, WordPress can display their initials instead.
In this tutorial, we’ll create this setup without enabling the standard WordPress avatar feature.
What This WordPress Customization Does
After installing the snippet, your website will have the following functionality:
- Authors can upload a profile photo from their WordPress profile.
- The photo is stored in the WordPress Media Library.
- The custom photo replaces the avatar in the Astra author box and other themes like Kadence.
- A smaller version appears beside the author’s name at the top of each article.
- If no photo is uploaded, the author’s initials are displayed.
- Gravatar and the WordPress avatar feature can remain disabled.
- Each author can manage their own photo.
For example:
- “Alexandru Dumitru” becomes “AD”.
- “Sarah Johnson” becomes “SJ”.
- “Michael” becomes “M”.
This is particularly useful for company blogs, editorial websites, agency websites, and other multi-author WordPress installations.
Requirements
This implementation is designed for websites using:
- WordPress
- The Astra/Kadence theme
- Astra’s author box
- The free Code Snippets plugin or a child theme
The larger author box is an Astra Pro feature. The small photo beside the post author’s name can also work with Astra’s normal post metadata.
Step 1: Disable the Default WordPress Avatars
If you do not want WordPress to use Gravatar, go to:
WordPress Dashboard → Settings → Discussion
Find the Avatars section and disable:
Show Avatars
Click Save Changes.
The custom author-photo system does not depend on this setting, so uploaded author photos and initials will continue to appear.
Step 2: Enable Astra’s Author Box
To display the larger author section below your articles, open:
Appearance → Customize → Blog → Single Post
Enable the Author Box or Author Info option and publish the changes.
The exact location of this option may differ slightly depending on your version of Astra and Astra Pro.
You can also configure the author box’s position, spacing, typography, colors, and other design options from the Astra Customizer.
Step 3: Install the Code Snippets Plugin
Using a snippets plugin is safer than adding custom code directly to your parent theme’s functions.php file. Changes made directly to the parent theme can be lost when the theme is updated.
From your WordPress dashboard:
- Go to Plugins → Add New Plugin.
- Search for Code Snippets.
- Install and activate the plugin.
- Go to Snippets → Add New.
- Give the snippet a name such as “Custom Author Photos”.
- Paste the complete custom-author-photo snippet into the code editor.
- Set it to run everywhere.
- Save and activate the snippet.
When using Code Snippets, do not include the opening <?php tag.
The snippet should contain the following components:
- The profile photo field
- The WordPress Media Library selector
- Photo-saving and security checks
- The initials generator
- The Astra author-box filter
- The Astra byline-photo filter
- The required CSS
All these components should remain in one snippet to avoid duplicate function names or conflicts between different versions of the code.
/**
* Universal WordPress author photos.
*
* Features:
* - Upload author photos from Users → Profile
* - Local images instead of Gravatar
* - Initials fallback
* - Small image beside the post author
* - Complete author box after the article
* - Kadence, Astra and standard WordPress theme support
*/
/* ============================================================
* 1. PROFILE PHOTO FIELD
* ============================================================ */
function hwa_universal_profile_photo_field($user) {
$photo_id = absint(
get_user_meta($user->ID, 'hwa_profile_photo_id', true)
);
$photo_url = $photo_id
? wp_get_attachment_image_url($photo_id, 'thumbnail')
: '';
wp_nonce_field(
'hwa_save_profile_photo_' . $user->ID,
'hwa_profile_photo_nonce'
);
?>
Author photo
|
This image will be used in post bylines and author boxes. If no image is selected, the author’s initials will appear.
|
<?php } add_action( ‘wp_head’, ‘hwa_universal_author_styles’ );
Step 4: Upload an Author Photo
After activating the snippet, go to:
Users → Profile
If you are editing another user as an administrator, go to:
Users → All Users → Edit
Scroll down until you find the new Author photo section.
Click Select photo and choose an image from the Media Library, or upload a new one. WordPress will display a preview of the selected image.
Click Update Profile to save it.
The selected photo is associated only with that WordPress user. Each author can therefore have a different image.
Recommended Image Format
For the best results, use a square image.
A recommended size is:
- 400 × 400 pixels
- 600 × 600 pixels
- 800 × 800 pixels
JPG and WebP are suitable for author photographs. PNG can be used for illustrations or profile graphics that require transparency.
The snippet uses object-fit: cover, so non-square images are cropped automatically when displayed inside a circular frame. However, uploading a square image gives you better control over the crop.
Before uploading the photo, compress it to avoid unnecessarily increasing the article’s page size.
How the Initials Fallback Works
Uploading a photo is optional.
When an author has not selected a profile photo, the snippet reads the user’s WordPress display name and generates initials automatically.
It uses the first letter of the first and last words in the display name. For example:
| WordPress display name | Initials |
|---|---|
| Alexandru Dumitru | AD |
| Maria Popescu Ionescu | MI |
| John Smith | JS |
| John | J |
The initials appear inside a colored circular background, giving the author box a complete and consistent appearance even when no photograph is available.
To change an author’s displayed name, open their WordPress profile and update the Display name publicly as setting.
Where the Author Photo Appears
The custom image can appear in two places on an Astra website.
In the Astra Author Box
A larger version appears in the author box below the article. It is displayed alongside:
- The author’s name
- Their biography
- A link to their author archive
- Any additional elements enabled through Astra
The author description comes from the Biographical Info field on the WordPress user profile.
Authors should complete this field if you want the author box to contain a short biography.
Beside the Author Name
A smaller version appears beside the author’s name in the post metadata near the top of the article.
This provides a visual connection between the byline and the complete author box below the article.
If no photo exists, the smaller circle also displays the author’s initials.
Customizing the Photo Size
The default large author-box image is 120 × 120 pixels.
Look for the following CSS in the snippet:
.hwa-author-photo,
.hwa-author-initials {
width: 120px;
height: 120px;
}
Change both values to adjust the size. For example:
.hwa-author-photo,
.hwa-author-initials {
width: 100px;
height: 100px;
}
The smaller image beside the author’s name is 28 × 28 pixels:
.hwa-small-author-photo,
.hwa-small-author-initials {
width: 28px;
height: 28px;
min-width: 28px;
}
You could change these values to 24px, 32px, or another size that fits your post design.
Changing the Initials Color
The initials currently use a blue background and white text:
background: #1e40af;
color: #fff;
Replace #1e40af with your website’s primary brand color.
For example, a dark charcoal background would use:
background: #1f2937;
color: #fff;
Make sure there is sufficient contrast between the background and the initials.
Updating or Removing a Photo
Authors can update their photo at any time:
- Go to Users → Profile.
- Find the Author photo section.
- Click Change photo.
- Select another image.
- Click Update Profile.
To remove it:
- Click Remove photo.
- Click Update Profile.
As soon as the image is removed, the website automatically falls back to the author’s initials.
Removing the photo from a user profile only removes the association between the user and the image. It does not necessarily delete the original file from the Media Library.
Troubleshooting
The Author Box Does Not Appear
Confirm that the author box is enabled in:
Appearance → Customize → Blog → Single Post
The author box is generally provided through Astra Pro’s Blog Pro module. Make sure the relevant Astra Pro module is active.
Also confirm that you are viewing a standard published WordPress post rather than a page.
The Photo Field Does Not Appear on the Profile
Check that the Code Snippets entry is active and configured to run everywhere.
If WordPress reports a PHP error, disable older author-photo snippets before activating the complete version. Running several versions at the same time can cause duplicate function-name errors.
The Photo Was Selected but Does Not Appear
After selecting the image, click Update Profile. Selecting the image in the Media Library does not save the user profile automatically.
Also clear:
- Your WordPress cache
- The Astra cache
- Your hosting cache
- Your CDN cache
- Your browser cache
Confirm that the article is assigned to the same user whose photo you updated.
The Initials Are Incorrect
The initials are generated from the user’s public display name.
Go to the user profile and check:
Display name publicly as
Choose the correct name and save the profile again.
The Small Photo Does Not Appear Beside the Name
Make sure the author is enabled in Astra’s post metadata:
Appearance → Customize → Blog → Single Post
The small image is inserted into Astra’s author metadata output, so the author meta element must be enabled.
Why Use Local Author Photos Instead of Gravatar?
Managing photos inside WordPress offers several advantages:
- Authors do not need separate Gravatar accounts.
- Administrators have direct control over the photos.
- Images remain consistent across the website.
- Photos can be updated without changing an account’s email address.
- The website does not need to request author images from Gravatar.
- New authors can use initials until a suitable photo is available.
This approach is especially helpful for business websites where author presentation needs to follow consistent branding.
Final Result
With one WordPress snippet, Astra website owners can create a complete local author-photo system without relying on Gravatar.
Authors upload their images from the familiar WordPress profile page. Their photo then appears automatically in the article byline and author box. When an image is unavailable, carefully styled initials keep the layout complete and professional.
The result is a more consistent author experience that remains fully managed from inside WordPress.
