aboutsummaryrefslogtreecommitdiff
path: root/internal/gallery/query_filter.go
diff options
context:
space:
mode:
authorRanXom <saiyedshizain@gmail.com>2026-07-22 18:20:15 +0530
committerRanXom <saiyedshizain@gmail.com>2026-07-22 18:20:15 +0530
commit8fb30a66a81a1f7150ebe86ed091e7c1651233a1 (patch)
treef23eb6ebdb05a0bfe6e998df5803dd687c8eaa85 /internal/gallery/query_filter.go
parenta9150facac14799f4d188062c01b6ed353d82588 (diff)
downloadgalleryd-8fb30a66a81a1f7150ebe86ed091e7c1651233a1.tar.xz
galleryd-8fb30a66a81a1f7150ebe86ed091e7c1651233a1.zip
feat(gallery): filter photos by extension
Diffstat (limited to 'internal/gallery/query_filter.go')
-rw-r--r--internal/gallery/query_filter.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/internal/gallery/query_filter.go b/internal/gallery/query_filter.go
new file mode 100644
index 0000000..9e10758
--- /dev/null
+++ b/internal/gallery/query_filter.go
@@ -0,0 +1,27 @@
+package gallery
+
+import (
+ "path/filepath"
+ "strings"
+)
+
+func filterQueryPhotos(
+ photos []Photo,
+ query Query,
+) []Photo {
+ if query.Extension == "" {
+ return photos
+ }
+
+ filtered := make([]Photo, 0, len(photos))
+
+ for _, photo := range photos {
+ ext := strings.TrimPrefix(filepath.Ext(photo.RelativePath), ".")
+
+ if strings.EqualFold(ext, query.Extension) {
+ filtered = append(filtered, photo)
+ }
+ }
+
+ return filtered
+}