more thumbnails

This commit is contained in:
Ryan Stafford 2023-07-07 13:57:01 -04:00
parent e46820ed3f
commit 0a4888906a
2 changed files with 10 additions and 5 deletions

View file

@ -36,7 +36,7 @@ summary {
transform: scale(1.03); transform: scale(1.03);
} }
.post { .post {
margin: 6px; margin: 6px 0px;
} }
.post .thumb { .post .thumb {
height: 52px; height: 52px;
@ -55,10 +55,10 @@ summary {
} }
.rank { .rank {
color: #c6c6c6; color: #c6c6c6;
font-size: medium; font-size: 14px;
margin-top: 17px; margin-top: 17px;
text-align: right; text-align: right;
min-width: 19px; min-width: 32px;
} }
.dark .post .rank { .dark .post .rank {
color: #646464; color: #646464;

View file

@ -115,10 +115,15 @@ var funcMap = template.FuncMap{
if p.ThumbnailURL.IsValid() { if p.ThumbnailURL.IsValid() {
return p.ThumbnailURL.String() + "?format=jpg&thumbnail=96" return p.ThumbnailURL.String() + "?format=jpg&thumbnail=96"
} }
re := regexp.MustCompile(`^https:\/\/i.imgur.com\/([a-zA-Z0-9]+)\.([a-z]+)$`) re := regexp.MustCompile(`\/pictrs\/image\/([a-z0-9\-]+)\.([a-z]+)$`)
if re.MatchString(p.URL.String()) {
return p.URL.String() + "?format=jpg&thumbnail=96"
}
re = regexp.MustCompile(`^https:\/\/i.imgur.com\/([a-zA-Z0-9]+)\.([a-z]+)$`)
if re.MatchString(p.URL.String()) { if re.MatchString(p.URL.String()) {
return re.ReplaceAllString(p.URL.String(), "https://i.imgur.com/${1}s.$2") return re.ReplaceAllString(p.URL.String(), "https://i.imgur.com/${1}s.$2")
} else if p.URL.IsValid() { }
if p.URL.IsValid() {
return "/_/static/link.png" return "/_/static/link.png"
} }
return "/_/static/text.png" return "/_/static/text.png"