mirror of
https://github.com/zedeus/nitter
synced 2026-09-05 22:59:31 +00:00
parent
44b2f096f6
commit
bfcf75af7f
3 changed files with 5 additions and 0 deletions
|
|
@ -40,12 +40,14 @@ proc getVidUrl*(link: string): string =
|
|||
&"/video/{sig}/{encodeUrl(link)}"
|
||||
|
||||
proc getPicUrl*(link: string): string =
|
||||
if link.len == 0: return
|
||||
if base64Media:
|
||||
&"/pic/enc/{encode(link, safe=true)}"
|
||||
else:
|
||||
&"/pic/{encodeUrl(link)}"
|
||||
|
||||
proc getOrigPicUrl*(link: string): string =
|
||||
if link.len == 0: return
|
||||
if base64Media:
|
||||
&"/pic/orig/enc/{encode(link, safe=true)}"
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -97,6 +97,7 @@ proc renderHead*(prefs: Prefs; cfg: Config; req: Request; titleText=""; desc="";
|
|||
link(rel="preload", type="image/png", href=bannerUrl, `as`="image")
|
||||
|
||||
for url in images:
|
||||
if url.len == 0: continue
|
||||
let preloadUrl = if "400x400" in url: getPicUrl(url)
|
||||
else: getSmallPic(url)
|
||||
link(rel="preload", type="image/png", href=preloadUrl, `as`="image")
|
||||
|
|
|
|||
|
|
@ -7,12 +7,14 @@ const smallWebp* = "?name=small&format=webp"
|
|||
const mediumWebp* = "?name=medium&format=webp"
|
||||
|
||||
proc getSmallPic*(url: string): string =
|
||||
if url.len == 0: return
|
||||
result = url
|
||||
if "?" notin url and not url.endsWith("placeholder.png"):
|
||||
result &= smallWebp
|
||||
result = getPicUrl(result)
|
||||
|
||||
proc getMediumPic*(url: string): string =
|
||||
if url.len == 0: return
|
||||
result = url
|
||||
if "?" notin url and not url.endsWith("placeholder.png"):
|
||||
result &= mediumWebp
|
||||
|
|
|
|||
Loading…
Reference in a new issue