Automattic / Co-Authors-Plus

Multiple bylines and Guest Authors for WordPress
https://wordpress.org/plugins/co-authors-plus/
GNU General Public License v2.0
291 stars 205 forks source link

Unable to change avatar image sizes #958

Closed douglas-johnson closed 1 year ago

douglas-johnson commented 1 year ago

While working on #940 ( specifically while trying to add coauthor avatars to the block editor ), I noticed that rest_get_avatar_urls() returned the same URL for all requested sizes.

rest_get_avatar_urls() uses get_avatar_url() as shown here https://developer.wordpress.org/reference/functions/rest_get_avatar_urls/

If I deactivate CoAuthors Plus, obviously there's no guest authors any more, but the user avatars start producing the correct size.

I believe the issues stem from filter_pre_get_avatar_data_url

Other uses of get_avatar() or get_avatar_url() in CoAuthors Plus that only return the default size for users, and the full resolution feature image for guest authors:

douglas-johnson commented 1 year ago

this one too: https://github.com/Automattic/Co-Authors-Plus/blob/3.5.11/co-authors-plus.php#L1275

douglas-johnson commented 1 year ago

I also noticed this issue #854 which describes avatars incorrectly cropped to the post-thumbnail size and wanted to correct myself because the default size used by get_the_post_thumbnail_url() is post-thumbnail rather than full.

I was testing on the TwentyTewntyThree theme which does not declare a post-thumbnail size.

In theory #959 would resolve that issue as well.

GaryJones commented 1 year ago

The gravatar size is set at 25. Can that be used to control the size for user gravatars and guest author avatars?

douglas-johnson commented 1 year ago

@GaryJones It could, but it would override user decisions like selecting the avatar size in the post comment or author block.

From looking at the git history, that size looks like its intended for the CAP admin tools like the coauthors meta box.

It can still be used for that and we can allow other parts of WP to request other sizes.

GaryJones commented 1 year ago

@douglas-johnson Understood. In which case, could #958 please include a separate commit that renames the $gravatar_size property (and its uses) to something like $gravatar_size_for_admin (or better) so that we can properly delineate what it should be used for, and to help clarify what the rest of the PR is, which is allowing other sizes elsewhere?

GaryJones commented 1 year ago

Other uses of get_avatar() or get_avatar_url() in CoAuthors Plus that only return the default size for users, and the full resolution feature image for guest authors

Nice finds - will you be handling this too 🤞🏻, and if so, will that be in #958 or separate PRs?

douglas-johnson commented 1 year ago

@GaryJones

Nice finds - will you be handling this too 🤞🏻, and if so, will that be in https://github.com/Automattic/Co-Authors-Plus/issues/959 or separate PRs?

Yes, those are addressed by #959.

Understood. In which case, could https://github.com/Automattic/Co-Authors-Plus/issues/959 please include a separate commit that renames the $gravatar_size property (and its uses) to something like $gravatar_size_for_admin (or better) so that we can properly delineate what it should be used for, and to help clarify what the rest of the PR is, which is allowing other sizes elsewhere?

I could rename it, but may I remove it instead?

After solving this issue, I think the only remaning use of $gravatar_size is here where it is used for a static display of coauthors in the case that an administative user has JavaScript turned off.

I don't think that use case would suffer from using the WordPress default of 96px. That's what the rest of CAP currently uses.

GaryJones commented 1 year ago

I could rename it, but may I remove it instead?

👍🏻 Please do!