impr(settings): Allow webp format for background images (@fehmer) (#6896)

This commit is contained in:
Christian Fehmer 2025-08-20 22:29:14 +02:00 committed by GitHub
parent 4aeadb9a85
commit 76597e6a08
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 5 additions and 5 deletions

View file

@ -751,7 +751,7 @@ describe("Config", () => {
Config.setCustomBackground(" http://example.com/test.png ")
).toBe(true);
expect(Config.setCustomBackground("http://www.example.com/test.webp")).toBe(
expect(Config.setCustomBackground("http://www.example.com/test.tiff")).toBe(
false
);
expect(

View file

@ -1376,7 +1376,7 @@
<input
type="file"
id="customBackgroundUpload"
accept="image/png,image/jpeg,image/jpg,image/gif"
accept="image/png,image/jpeg,image/jpg,image/gif,image/webp"
style="display: none"
/>
</div>

View file

@ -42,7 +42,7 @@ const customBackgroundCommand: Command = {
}
// check type
if (!file.type.match(/image\/(jpeg|jpg|png|gif)/)) {
if (!file.type.match(/image\/(jpeg|jpg|png|gif|webp)/)) {
Notifications.add("Unsupported image format", 0);
cleanup();
return;

View file

@ -52,7 +52,7 @@ uploadContainerEl
}
// check type
if (!file.type.match(/image\/(jpeg|jpg|png|gif)/)) {
if (!file.type.match(/image\/(jpeg|jpg|png|gif|webp)/)) {
Notifications.add("Unsupported image format", 0);
fileInput.value = "";
return;

View file

@ -345,7 +345,7 @@ export const CustomBackgroundSchema = z
.url("Needs to be an URI.")
.regex(/^(https|http):\/\/.*/, "Unsupported protocol.")
.regex(/^[^`'"]*$/, "May not contain quotes.")
.regex(/.+(\.png|\.gif|\.jpeg|\.jpg)/gi, "Unsupported image format.")
.regex(/.+(\.png|\.gif|\.jpeg|\.jpg|\.webp)/gi, "Unsupported image format.")
.max(2048, "URL is too long.")
.or(z.literal(""));
export type CustomBackground = z.infer<typeof CustomBackgroundSchema>;