[GITEA] Maintain aspect ratio for auth icons

- When specifying an icon URL for a authentication source, it's forced
to be an width and height of 20px. However this didn't take into account
that icons could have an different aspect ratio of 1:1.
- This patch fixes that by instead using `max-width` and `max-height`
which will respect other aspect ratios.
- Resolves https://codeberg.org/forgejo/forgejo/issues/1234
This commit is contained in:
Gusted 2023-08-11 12:35:30 +02:00
parent cb1ec27be4
commit 3482739637
No known key found for this signature in database
GPG key ID: FD821B732837125F
2 changed files with 6 additions and 1 deletions

View file

@ -56,7 +56,7 @@ func (p *AuthSourceProvider) DisplayName() string {
func (p *AuthSourceProvider) IconHTML() template.HTML { func (p *AuthSourceProvider) IconHTML() template.HTML {
if p.iconURL != "" { if p.iconURL != "" {
img := fmt.Sprintf(`<img class="gt-mr-3" width="20" height="20" src="%s" alt="%s">`, img := fmt.Sprintf(`<img class="gt-mr-3 oauth-provider-icon" src="%s" alt="%s">`,
html.EscapeString(p.iconURL), html.EscapeString(p.DisplayName()), html.EscapeString(p.iconURL), html.EscapeString(p.DisplayName()),
) )
return template.HTML(img) return template.HTML(img)

View file

@ -2289,3 +2289,8 @@ table th[data-sortt-desc] .svg {
flex-wrap: wrap; flex-wrap: wrap;
gap: .25rem; gap: .25rem;
} }
.oauth-provider-icon {
max-height: 20px;
max-width: 20px;
}