go-gitea / gitea

Git with a cup of tea! Painless self-hosted all-in-one software development service, including Git hosting, code review, team collaboration, package registry and CI/CD
https://gitea.com
MIT License
44.98k stars 5.48k forks source link

User avatar in profile page changed from s=290 to s=580 while rendered at s=128 anyway #16287

Closed strk closed 2 years ago

strk commented 3 years ago

Gitea 1.14.3 is requesting Libravatar avatar images with size 580 in profile page while rendering them at 128x128. Older versino 1.12.3 was requesting a size of 290 instead.

I think it would make sense to request s=128 instead, to reduce the download time

zeripath commented 3 years ago

See https://github.com/go-gitea/gitea/issues/15453

strk commented 3 years ago

That ticket shows that passing a size is what changed, but doesn't explain why we're passing a size of 580 when rendering the image at 128, is that an UI issue which went unnoticed before ?

strk commented 3 years ago

It got worst, now the avatar image is requested at size 1160 ! See https://try.gitea.io/strk

I noted that models/avatars/avatar.go has a const AvatarRenderedSizeFactor = 4 which would then match the older version size of 290 (290 x 4 == 1160).

strk commented 3 years ago

290 constant is still present in modules/avatar/avatar.go:

// AvatarSize returns avatar's size
const AvatarSize = 290

What was the AvatarRenderedSizeFactor introduced for ?

It looks like be745be0a4f3feab01f896f1c0f17164bb30234b doubled it from a factor of 2 to a factor of 4 to get better avatars for Hi-DPI displays but, shouldn't all of this be decided by the frontend code and based on actual displays ?

\cc @techknowlogick @zeripath ref #15941

wxiaoguang commented 3 years ago

It got worst, now the avatar image is requested at size 1160 ! See https://try.gitea.io/strk

I noted that models/avatars/avatar.go has a const AvatarRenderedSizeFactor = 4 which would then match the older version size of 290 (290 x 4 == 1160).

Although the requested size looks like 1160, but the real responded image is not that big, it isn't a big problem now.

But, I believe we should make the avatar size problem correct.

strk commented 3 years ago

Although the requested size looks like 1160, but the real responded image is not that big, it isn't a big problem now.

The image is not big because my avatar service is being nice and refusing to serve such a big image, but what Gitea requests should match what it actually will want to render on the screen. The generated HTML looks like this:

<img class="ui avatar image" src="/avatar/fe2a9e759730ee64c44bf8901bf4ccc3?size=1160" title="strk" width="290" height="290">

Doesn't make sense, right ? It will render at 290x290 no matter what the /avatar link will return, but it asks the /avatar link for a 1160x1160 image. Doesn't make sense to me

strk commented 3 years ago

The culprit seems to be the Avatar helper in modules/templates/helper.go which applies the RenderedSizeFactor to the size requested by the template

strk commented 2 years ago

Unfortunately the default size factor of 3 still breaks my avatar: https://try.gitea.io/strk (is requested at 870x870 I still think this should be based on actual user monitor rather than expecting a "one size fits all" as it is now.