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{
display: block;
}
.expando .embed {
text-align: center;
}
.expando .image {
max-width: 578px;
}

View file

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