Random Default Avatar Function

The function get_avatar‘s 3rd argument is the default image, which you can also pass a function’s return value to, so wherever you run get_avatar in your theme you can set a function that changes the default avatar as a 3rd argument.

get_avatar( get_the_author_meta( 'user_email' ), 64, 'http://example.com/path/to/image.jpg' );

Or, with a function’s return value as third argument:

get_avatar( get_the_author_meta( 'user_email' ), 64, figure_out_new_default_image() );

This IMO is the best place to pass the default image information to, since the $avatar_defaults is for setting up a singular image that can be configured in Settings > Discussion of wp-admin.

error code: 523