Skip to content

Commit

Permalink
Skip grid if grid image only has 1 img
Browse files Browse the repository at this point in the history
  • Loading branch information
Wikidepia committed Jul 6, 2024
1 parent 47fc5af commit a0d9c7f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions handlers/grid.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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}
Expand Down

0 comments on commit a0d9c7f

Please sign in to comment.