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?
- Woocommerce: assign an “author” to a product
- Removing Gravatar.com support for WordPress and Simple Local Avatars
- Programatically change post author
- Restrict one post per author
- Author page: Comments and Ratings?
- Add rewrite endpoint to author page + pagination
- Setting different width and height for gravatar
- How can an author be subscribed to the posts of another author and receive notifications of the new posts?
- 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
- Creating distinct pages for author profiles and lists of posts by author
- Making WordPress author follow button, need missing ingredient
- Listing all users by their avatars in wordpress
- Get the comment author ID by the comment ID
- Author profile visitors in last 7 days in front end without plugins
- How To Remove The Author(s) From Certain Posts
- Remove /author/ from the author profile url
- Google Authorship on a multi-author blog?
- Change author base slug to user role
- Display Author role in archive or author page
- How to Add Author Editing Capability to Existing Post by Admin
- 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?
- Author list ‘special’ author first then ‘normal’ author
- hide something in single page if current author has only one post
- get_the_author_meta( $field, 0 ) returns the administrator $field
- Use Gravatar as fallback image if no local image is not found
- Plugin for an author bio popup box?
- How to link to the current User/Author Profile page?
- Author website URL
- How can I get the author description’s excerpt?
- How to use Buddypress xProfile field as WordPress Bio
- What do you put in child themes author tag?
- Make user as Default contributor for all Blog Posts
- How to list the authors of all revisions?
- Link Author’s Website in Author Bio
- Post list based on the page author
- How to set post author to custom post field via front-end form?
- Remove hovercard for only certian gravatars
- Show Author information on post page on dashboard
- Display emails of users who already posted at least once
- Get author’s first name
- Display only author posts in dashboard all posts panel
- Breadcrumbs – get the author?
- Display author name, outside the loop, if they haven’t published a custom post
- Is author.php a core file?
- Allow Google crawler to crawl specific Author pages
- Change the “Default Avatar” admin option via functions.php
- Clean links in: the_author_meta(‘description’)
- Add Date and Author to Posts
- How to restrict an author scheduling their post date to a maximum X days ahead from the current date
- Different posttypes for different authors
- Create an Author Page on Registration
- author slug in the backend
- Custom Field Repeating When Using foreach
- Can I Include author login in post class?
- Disable WordPress Comment Author Name
- Condition within single.php to send an email to the post author
- Author Page Create Link to Page That Lists All Author’s Posts?
- Unpublish Authors With not Fulfilled Fields
- Display Recent Posts in BuddyPress Profile
- Display All Authors only
- How to get all users that uploaded avatars or have gravatars? [closed]
- How to reorder the content of the single post?
- Possible to switch between admin view and author view?
- How to show author page link
- Add Post Author body class to WordPress
- Improving Co-Authors Plus Plugin [closed]
- Show Published and Draft posts from Logged in Author
- WHen I click on post author (on frontend) it doesn’t go to author page
- WordPress Custom Local Avatar not showing in comments
- How to fix a specific page (author archive) loading speed?
- Show text only to the author of the article
- Display Random Post in Author Page
- Show author image at home page latestest posts plugin
- Open the_author_link() in a new window
- WordPress author box
- Show custom default avatar instead of gravatar
- Author page link in comments is different than in posts?
- Author Link Not Displaying
- Broken Gravatar images in comments
- Change Post and CPT author on the fly while publish the post
- Profile Field In Admin Bar
- Show the most recent post for an author on the author page
- How do I add nopin=”nopin” to the default avatar?