Skip to content

Commit a22be2e

Browse files
authored
Check for image extensions
Rather than filter out a few non-image extensions (such as git, js, etc), check from a list of supported image extensions for the browser and remove any files that do not contain those image extensions.
1 parent 0a225c1 commit a22be2e

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

BrowserImageSlideshow.html

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,17 @@
3636
// 1: Alphabetical order
3737
// 2: Alphabetical order (start on random image)
3838

39+
// common extensions from here https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Image_types
40+
const imageExtensions = ["apng", "avif", "gif", "jpg", "jpeg", "jfif", "pjpeg", "pjp", "png", "svg", "webp", "bmp", "ico", "cur"];
41+
3942
// setup image src strings
4043
let images = imageNamesStr.split("\n");
4144
images.shift();
4245
images.pop();
4346
for (let i = images.length-1; i >= 0; i--) {
44-
// remove js, sh, or directory
45-
let remove = images[i].includes(".js") || images[i].includes(".sh") || !images[i].includes(".") || images[i].includes(".git");
46-
if (remove) {
47+
let fileName = images[i];
48+
// remove anything that's not an image
49+
if (!imageExtensions.some(v => fileName.includes("."+v))) {
4750
images.splice(i, 1);
4851
}
4952
}

0 commit comments

Comments
 (0)