One option is to use the pre_get_avatar
filter to return custom avatar HTML, which will short-circuit get_avatar()
preventing it from reaching out to Gravatar for the image.
For example like this,
add_filter('pre_get_avatar', 'wpse_410434_author_img_html', 10, 3);
function wpse_410434_author_img_html( $avatar, $id_or_email, $args ) {
if ( $avatar || ! is_numeric( $id_or_email ) ) {
return $avatar;
}
$upload_dir = wp_upload_dir();
return sprintf(
'<img class="my-author-avatar" src="%1$s" alt="" width="%2$d" height="%2$d">',
esc_url(sprintf(
'%s/author%d.jpg',
$upload_dir['baseurl'],
absint( $id_or_email )
)),
esc_attr( $args['size'] )
);
}
N.B Untested, but should work. Tweak to match your exact setup and needs.
Related Posts:
- How to add avatar to authors list?
- If Else Gravatar Author Picture
- Get only the author profile picture image url inside a loop
- Replace Gravatar with img URL for avatars
- How to link avatar and nickname to profile
- Custom avatar image link added to the profile page
- Get avatar of the logged-in user in WordPress
- Working with Gravatars within a localhost development area
- Display Authors avatars when more than one author
- Simple Local Avatar Plugin
- List of all authors avatars
- Yoast SEO plugin open graph add meta tag to fetch Avatar from Author Page
- Show author name not the author ID
- How to check if a user (not current user) is logged in?
- How to remove the author pages?
- Select subscriber as author of post in admin panel?
- Echo author ID in author.php
- Woocommerce: assign an “author” to a product
- How can HTML be allowed in Author Bio?
- Removing Gravatar.com support for WordPress and Simple Local Avatars
- Programatically change post author
- Restrict one post per author
- How to get author’s name by author’s id
- Author page: Comments and Ratings?
- Give Author users the right to embed
- How to get post author name by its ID inside a function?
- How can I publish a post with two or more authors?
- Custom user avatar in the WordPress users listing
- Displaying custom post types in author.php
- Add rewrite endpoint to author page + pagination
- Order the users by the date of their latest post
- What’s a good way to put authors into groups
- Upload gravatar in WP profile?
- How to check if gravatar of user is the default’s one?
- Setting different width and height for gravatar
- Permalink to user profile
- Show Author in custom rss feed
- Use local image for default avatar
- Wrong gravatar showing up?
- What is the difference between user_description and description?
- How can an author be subscribed to the posts of another author and receive notifications of the new posts?
- No authors in change author dropdown
- Show author archive pages for authors with no posts
- More posts from the current author
- List authors of site with link and gravatar
- How we can get the author ID by its Name
- How to hide posts count and posts of other users from edit.php for contributors and authors
- User Published Post Count
- Custom size for image uploaded to custom field in user profile?
- What capability allows someone to change a page’s/post’s author?
- Alternative default avatar generator?
- How to get posts without author?
- Creating distinct pages for author profiles and lists of posts by author
- Allow Content Author to Publish, But Not Edit or Delete
- Just wanted to Pull Author’s Link
- Making WordPress author follow button, need missing ingredient
- How to get gravatar url alone
- list author’s posts in author.php
- Replace default avatar
- Listing all users by their avatars in wordpress
- Get the comment author ID by the comment ID
- How to replace any occurence of Gravatars with a local placeholder image?
- Author profile visitors in last 7 days in front end without plugins
- How to output nothing instead of default avatar?
- get the avatar url instead of an html img tag when using get_avatar?
- How To Remove The Author(s) From Certain Posts
- Is it possible to set/override default the_author_posts_link to login name?
- add capability to author role to be able to delete attachments
- Remove /author/ from the author profile url
- Google Authorship on a multi-author blog?
- Changing default Buddypress avatar affects all site avatars (because gravatar)
- Change author base slug to user role
- Get the excerpt for a post created by the related author
- Custom Author Fields + Existing Taxonomy – Integrating the Two Dynamically?
- Display Author role in archive or author page
- How to Add Author Editing Capability to Existing Post by Admin
- WordPress Author Page
- get the username of a user in his author page
- Editing the loop for Author pages
- What is wrong with this code?
- Limit REST API output to current logged in user that is also author of the content
- Display only entire most recent post on author page?
- Assign a random avatar to every user?
- I only want to Display Author Link in authors bio
- Replace comment avatars and links at the same time
- How can I add “posted by ‘author'” to each post?
- Is it possible to get_terms by author?
- get_avatar() default image not working as of wp 3.5 [closed]
- no emails for a user account
- Author list ‘special’ author first then ‘normal’ author
- hide something in single page if current author has only one post
- Cannot get local avatars to show [closed]
- Show selected value in a drop down menu
- Can I stop authors from changing the font in their post?
- Author page doesn’t change after username change [duplicate]
- Custom Author Loop
- Output author and description if description is not empty
- get_the_author_meta( $field, 0 ) returns the administrator $field
- WP authors page
- Use Gravatar as fallback image if no local image is not found