I had this problem, too. Here’s the solution for version 4.7.3 if anyone comes across this.
get_avatar( $id_or_email = get_the_author_meta( 'user_email' ), $size="60", $default, $alt, $args = array( 'class' => array( 'd-block', 'mx-auto' ) ) );
or shorter version
get_avatar( get_the_author_meta( 'user_email' ), '60', $default, $alt, array( 'class' => array( 'd-block', 'mx-auto' ) ) );
For some reason, all the parameters have to be present or it doesn’t work.
This method, unlike the functions.php method, will not alter get_avatar globally. So you can have different classes like “post-author” or “comments-author”.
Related Posts:
- How do I get the avatar URL instead of an HTML IMG tag when using get_avatar?
- Use Gravatar as fallback image if no local image is not found
- How do I get a smaller size of an avatar image
- Simple Local Avatar Plugin
- How to have a specific image show up for everyone who comments?
- Change the avatar ratio?
- Convert User’s Avatar/Gravatar to a jpg or png on the Fly
- What’s the proper way to find and remove duplicate images from posts and the media library?
- get_post_gallery with Gutenberg
- Insert an image into a post by API
- Saving the pre-sanitized filename of an attachment as the Title or Caption
- Creating a rotating header /image slider using theme customization
- hide/protect original full-size images
- How to grab first image attached to post and display in RSS feed?
- How to add a link in a image’s caption?
- Displaying a featured image (only img url) as the img src?
- Adjusting caption below single post image
- Wrap all post images inside a div element
- When displaying the featured image, is has_post_thumbnail() necessary?
- Uploading images to Media Library fails with Memory Exhausted
- Image display from custom field
- Include captions
- Replacing image attributes (data-src) also applies to backend
- What’s the proper way to use the get_image_tag filter?
- Populate a slideshow list of images from images in a wordpress page?
- Using Add_image_size when adding image in post
- Resizing image into thumbnail, small, medium and large options greyed out
- Add multiple images to author profile page
- Is there a plugin or simple way to add a multiple images metabox to a post?
- how to attach an image to a custom post type in wordpress using just code
- Show media url immediately after upload in media uploader
- Image URLs stopped working due to Permalinks?
- Is this post using WordPress Gallery?
- can you call the alt tag for an image dynamically?
- How to open default wp image editor screen dynamically?
- How can I add a “data-pin-nopin” the featured image html?
- Hardcoded Images Too Big
- update_post_meta attachment_image_alt description for Gutenberg
- Add select input with pre defined classes to insert image screen?
- Is there a way to change all already uploaded images which are PNG and convert them to JPG?
- Auto delete attachments that are older than x days
- Image increasing kb on resize
- attach image from library to post with wp_insert_attachment
- Bulk-add featured images in posts with no featured image
- Media gallery images url instead of ID on WP API Response
- How to get image from media library with URL [duplicate]
- WordPress Creates Unused (Unregistered) Image Sizes
- Custom image uploader without widgets
- How to upload and style svg logo?
- How to change the catalog product image size by product id?
- Get all custom sizes in srcset attribute
- are unattached media files a problem?
- Why isn’t add_image_size(‘event-secondary-image-thumbnail’, 250, 150) working?
- Disable image rename on upload
- Development environment and “production” environment domains
- HTTP error when uploading an image
- Why am I getting and error from wp_get_attachment_image_src?
- How do I implement an image viewer and rotator? [closed]
- Upload images – Theme options
- How to replace post image url before posting using api?
- How to get post id of first child of the same post type?
- Product Images Making a Column
- What’s are some best practices for responsive images (e.g. for section headers)?
- WordPress Single Post image gallery as slider
- Recreate the upload folder from a website without having access to the backend/cpanel/filezilla directly from the website
- how automatically show the image title before the image caption/description in a wordpress gallery?
- change the h3 subtitles of the wordpress gallery shortcode
- Hot Linked Own Images
- imported post image as normal image instead encoded image
- Updated wordpress missing image upload area
- Allow users to upload attachments to certain posts
- WordPress and Advanced Custom Fields and Flickity
- How to get image ID based on get_theme_mod image URL?
- Site not showing Image in WordPress and in HTML code also which uploaded in root what is the solution for this?
- How to bulk update then save images in wordpress posts
- How to set a post featured image from an already made custom field
- Change wordpress default upload path to another domain
- Alt attribute is not showing while the value is given in Media
- Alternative image sizes are too large
- Responsive images in Bootstrap 4 slider
- How can I add an “Attach image to this post/page” link on the Add Media lightbox?
- How to call thumbnail by aqua resizer in best practice. Specify image dimensions’s notify from GTmetrix
- How do i replace the title attribute of img tag with the image caption
- Create slider option in editor
- Assign one featured image to multiple posts?
- Why are my ‘medium’ images the wrong size
- How can I hide previous_image_link() on first attachment page?
- wp_get_attachment_image_src
- An image on my site is showing as the wrong image [closed]
- Set padding for all content except images and few more elements
- Theme files and imagesnot loading on a mobile device
- Guaranteed Image Sizes
- How to change the alignment of the background image for small screen (tablet/smartphone etc.)
- get_theme_file_uri function not showing background image inside data-setbg in html
- How to show file type of featured image?
- WordPress update leads to 404 error on admin page and signup. CSS mishap with all plugin related functions
- How to get dimension of Logo and Crest
- WordPress Missing Images
- Display first image’s caption
- The uploaded images are only full-size (original)