handle expandos for images with query parameters

This commit is contained in:
Ryan Stafford 2023-12-22 13:09:40 -05:00
parent de281c00ee
commit e0d7290e51
2 changed files with 8 additions and 6 deletions

View file

@ -548,9 +548,6 @@ form.blockpost {
.expando.open{ .expando.open{
display: block; display: block;
} }
.expando .embed {
text-align: center;
}
.expando .image { .expando .image {
max-width: 578px; max-width: 578px;
} }

View file

@ -12,6 +12,7 @@ import (
"net/http" "net/http"
"net/url" "net/url"
"os" "os"
"path/filepath"
"regexp" "regexp"
"strconv" "strconv"
"strings" "strings"
@ -111,9 +112,13 @@ var funcMap = template.FuncMap{
} }
return "" return ""
}, },
"isImage": func(url string) bool { "isImage": func(u string) bool {
ext := url[len(url)-4:] p, err := url.Parse(u)
if ext == "jpeg" || ext == ".jpg" || ext == ".png" || ext == "webp" || ext == ".gif" { if err != nil || p.Path == "" {
return false
}
ext := filepath.Ext(p.Path)
if ext == ".jpeg" || ext == ".jpg" || ext == ".png" || ext == ".webp" || ext == ".gif" {
return true return true
} }
return false return false