Is there any way to change the aspect ratio of the WordPress Avatars? Or is this hardcoded?
- Use Css with something like
overflow: hidden;and "cut out" what you need.
- Use the filter
apply_filters('get_avatar', $avatar, $id_or_email, $size, $default, $alt);and override the output of
- The function
get_avatar()is pluggable. That means if you hook a plugin function early enough that already defines
get_avatar()then this function will be used instead of the core function. See Core (link).
It's a bit of a hack, but you can hard-code a new crop ratio by changing line 566 of wp-content/plugins/buddypress/bp-core/js/avatar.js from...
... replacing 1.72817 with the aspect ratio of your choice of course.
Note you will also have to edit the same bit in avatar.min.js for it to work.
As it is a hack, you will have to be careful when updating Buddypress and you may have to keep re-applying the change. So if you can do it without hacking the core files then do that!