From 183fd0fdddbcf194eec08f8e79e6a1709e18d3a9 Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Wed, 3 Sep 2025 12:20:42 +0200 Subject: also do bgs --- webAO/dom/updateBackgroundPreview.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'webAO/dom') diff --git a/webAO/dom/updateBackgroundPreview.ts b/webAO/dom/updateBackgroundPreview.ts index 61186e0..2b8a18b 100644 --- a/webAO/dom/updateBackgroundPreview.ts +++ b/webAO/dom/updateBackgroundPreview.ts @@ -1,5 +1,20 @@ import { AO_HOST } from "../client/aoHost"; -import tryBackgroundUrls from "../utils/tryBackgroundUrls"; +import fileExists from "../utils/fileExists"; +import transparentPng from "../constants/transparentPng"; + +const urlExtensionsToTry = [".png", ".gif", ".webp", ".apng"]; +const tryBackgroundUrls = async (url: string) => { + for (let i = 0; i < urlExtensionsToTry.length; i++) { + const extension = urlExtensionsToTry[i]; + const fullFileUrl = url + extension; + const exists = await fileExists(fullFileUrl); + if (exists) { + return fullFileUrl; + } + } + return transparentPng; +}; +export default tryBackgroundUrls; /** * Update background preview. -- cgit