From a0d9c7fae53f4a749094ba77ccd49c448169f0d3 Mon Sep 17 00:00:00 2001 From: Akmal Date: Sat, 6 Jul 2024 20:18:34 +0700 Subject: [PATCH] Skip grid if grid image only has 1 img --- handlers/grid.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/handlers/grid.go b/handlers/grid.go index 8545775..9eeb2da 100644 --- a/handlers/grid.go +++ b/handlers/grid.go @@ -141,10 +141,6 @@ func Grid() fiber.Handler { return err } - if len(item.Medias) == 1 { - return c.Redirect("/images/" + postID + "/1") - } - // Filter media only include image var mediaURLs []string for _, media := range item.Medias { @@ -154,6 +150,10 @@ func Grid() fiber.Handler { mediaURLs = append(mediaURLs, media.URL) } + if len(item.Medias) == 1 || len(mediaURLs) == 1 { + return c.Redirect("/images/" + postID + "/1") + } + var wg sync.WaitGroup images := make([]image.Image, len(mediaURLs)) client := http.Client{Transport: transport, Timeout: timeout}