Skip to content

armgit / fider

Public Imported from GitHub
0

Open platform to collect and prioritize feedback

enhancement: better logo contraints (#381)

Guilherme Oenning57a385441316
diff --git a/app/actions/tenant.go b/app/actions/tenant.go
index 111860fe5..fea860ef2 100644
--- a/app/actions/tenant.go
+++ b/app/actions/tenant.go
@@ -101,12 +101,16 @@ func (input *UpdateTenantSettings) Validate(user *models.User, services *app.Ser
return validate.Error(err)
}
} else {
- if logo.Width > 200 || logo.Height > 200 {
- result.AddFieldFailure("logo", "The image must be smaller than 200x200 pixels in dimension.")
+ if logo.Width < 200 || logo.Height < 200 {
+ result.AddFieldFailure("logo", "The image must have minimum dimensions of 200x200 pixels.")
}
- if logo.Size > 51200 {
- result.AddFieldFailure("logo", "The image size must be smaller than 50KB.")
+ if logo.Width != logo.Height {
+ result.AddFieldFailure("logo", "The image must have an aspect ratio of 1:1.")
+ }
+
+ if logo.Size > 102400 {
+ result.AddFieldFailure("logo", "The image size must be smaller than 100KB.")
}
}
}
diff --git a/app/actions/tenant_test.go b/app/actions/tenant_test.go
index b6cab471b..32823340a 100644
--- a/app/actions/tenant_test.go
+++ b/app/actions/tenant_test.go
@@ -120,10 +120,11 @@ func TestUpdateTenantSettings_LargeLogo(t *testing.T) {
fileName string
valid bool
}{
- {"/app/pkg/img/testdata/logo1.png", false},
+ {"/app/pkg/img/testdata/logo1.png", true},
{"/app/pkg/img/testdata/logo2.jpg", false},
{"/app/pkg/img/testdata/logo3.gif", false},
- {"/app/pkg/img/testdata/logo4.png", true},
+ {"/app/pkg/img/testdata/logo4.png", false},
+ {"/app/pkg/img/testdata/logo5.png", true},
{"/README.md", false},
{"/favicon.ico", false},
}
diff --git a/app/pkg/img/img_test.go b/app/pkg/img/img_test.go
index ebb69a488..19ac37ccc 100644
--- a/app/pkg/img/img_test.go
+++ b/app/pkg/img/img_test.go
@@ -19,6 +19,7 @@ var testCases = []struct {
{"/app/pkg/img/testdata/logo2.jpg", 2624, 2184, true},
{"/app/pkg/img/testdata/logo3.gif", 1165, 822, true},
{"/app/pkg/img/testdata/logo4.png", 150, 150, true},
+ {"/app/pkg/img/testdata/logo5.png", 200, 200, true},
{"/favicon.ico", 0, 0, false},
}
diff --git a/app/pkg/img/testdata/logo5.png b/app/pkg/img/testdata/logo5.png
new file mode 100644
index 000000000..7ef08b79b
Binary files /dev/null and b/app/pkg/img/testdata/logo5.png differ
diff --git a/app/pkg/web/renderer.go b/app/pkg/web/renderer.go
index 809d493d0..0b6dd85a6 100644
--- a/app/pkg/web/renderer.go
+++ b/app/pkg/web/renderer.go
@@ -89,7 +89,7 @@ func (r *Renderer) Render(w io.Writer, name string, data interface{}, ctx *Conte
m["__StyleBundle"] = r.cssBundle
m["__ContextID"] = ctx.ContextID()
if ctx.Tenant() != nil && ctx.Tenant().LogoID > 0 {
- m["__logo"] = fmt.Sprintf("/logo/%d", ctx.Tenant().LogoID)
+ m["__logo"] = fmt.Sprintf("%s/logo/%d", ctx.BaseURL(), ctx.Tenant().LogoID)
m["__favicon"] = m["__logo"]
} else {
m["__logo"] = "https://getfider.com/images/logo-100x100.png"
diff --git a/public/pages/Administration/pages/GeneralSettings.page.tsx b/public/pages/Administration/pages/GeneralSettings.page.tsx
index 5e88cda52..58f7e3c2c 100644
--- a/public/pages/Administration/pages/GeneralSettings.page.tsx
+++ b/public/pages/Administration/pages/GeneralSettings.page.tsx
@@ -178,7 +178,10 @@ export class GeneralSettingsPage extends AdminBasePage<GeneralSettingsPageProps,
</Button>
)}
</div>
- <p className="info">We accept JPG, GIF and PNG images, smaller than 50KB and 200x200 pixels in dimension.</p>
+ <p className="info">
+ We accept JPG, GIF and PNG images, smaller than 100KB and with an aspect ratio of 1:1 with minimum
+ dimensions of 200x200 pixels.
+ </p>
</div>
{!page.isSingleHostMode() && [