This code enables you to use a custom image in replace of a Gravatar hosted image for any author in any WordPress theme. You can add the images for each author in your child themes images folder.
Update : You’ll also find a 2nd solution which enables each user to upload a custom image which replaces the default avatar connected to their email address.
Here’s the demo video which shows Author 1 using a Gravatar hosted image and all other authors using a custom avatar.
There’s 3 simple steps:
Step 1 : Paste the PHP code below to the end of your child themes functions file.
Step 2 : Swap out the author id in the code to match the user id for each author. You can get each author id simply by hovering over the delete link on the Users > All Users admin page like you see in the following screenshot:
Step 3 : Add a image for each author to your child themes images folder like you see in the following screenshot:
Make sure the image file name for each author matches the file name in the PHP code.
This solution enables you to customize the authors image using code in your child theme rather than a plugin. The custom avatar image will display in the author box as well as the comments.
Here’s the code for logged in members: