feat: add support for custom favicons (#4770)

* feat: add support for custom favicons

* Commit updated API documentation

* chore(i18n): add localization of text

* fix(js): regenerate package lock file

* chore(test): add favicon test

* fix: max size not respected

* Commit updated API documentation

* fix: move favicon.ico to the static dir

* fix: fix tests

* fix: remove hard-coded content-type of icon

* chore: update extracted translations

* feat(admin): add support for resetting to default icon

* chore: use a higher res default favicon

* Commit updated API documentation

---------

Co-authored-by: Owncast <owncast@owncast.online>
This commit is contained in:
Gabe Kangas
2026-01-28 18:07:19 -08:00
committed by GitHub
co-authored by Owncast
parent f8560db614
commit 6abaf20f2b
77 changed files with 981 additions and 177 deletions
+4 -1
View File
@@ -1,6 +1,9 @@
export const MAX_IMAGE_FILESIZE = 2097152;
export const ACCEPTED_IMAGE_TYPES = ['image/png', 'image/jpeg', 'image/gif'];
export const MAX_FAVICON_FILESIZE = 204800; // 200KB
export const ACCEPTED_FAVICON_TYPES = ['image/png', 'image/x-icon', 'image/vnd.microsoft.icon'];
export function getBase64(img: File | Blob, callback: (imageUrl: string | ArrayBuffer) => void) {
const reader = new FileReader();
reader.addEventListener('load', () => callback(reader.result));
@@ -10,7 +13,7 @@ export function getBase64(img: File | Blob, callback: (imageUrl: string | ArrayB
export function readableBytes(bytes: number): string {
const index = Math.floor(Math.log(bytes) / Math.log(1024));
const SIZE_UNITS = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
const size = Number((bytes / Math.pow(1024, index)).toFixed(2)) * 1;
const size = Number((bytes / 1024 ** index).toFixed(2)) * 1;
return `${size} ${SIZE_UNITS[index]}`;
}