Skip to content

Commit 742131c

Browse files
committed
Add image limit
1 parent a19d0cc commit 742131c

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

web/js/imageFeed.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,14 @@ Recommended: "enabled (max performance)" uness images are erroneously deduplicat
367367
},
368368
});
369369

370+
const maxImages = app.ui.settings.addSetting({
371+
id: "pysssss.ImageFeed.MaxImages",
372+
name: "🐍 Image Feed Max Images",
373+
tooltip: `Limits the number of images in the feed to a maximum, removing the oldest images as new ones are added.`,
374+
defaultValue: 0,
375+
type: "number",
376+
});
377+
370378
const clearButton = $el("button.pysssss-image-feed-btn.clear-btn", {
371379
textContent: "Clear",
372380
onclick: () => {
@@ -399,6 +407,11 @@ Recommended: "enabled (max performance)" uness images are erroneously deduplicat
399407

400408
function addImageToFeed(href) {
401409
const method = feedDirection.value === "newest first" ? "prepend" : "append";
410+
411+
if (maxImages.value > 0 && imageList.children.length >= maxImages.value) {
412+
imageList.children[method === "prepend" ? imageList.children.length - 1 : 0].remove();
413+
}
414+
402415
imageList[method](
403416
$el("div", [
404417
$el(

0 commit comments

Comments
 (0)