mirror of
https://github.com/zedeus/nitter.git
synced 2024-12-23 03:45:36 +00:00
Use webp for thumbnails when available
This commit is contained in:
parent
88c6135030
commit
cd163b26a3
|
@ -98,9 +98,8 @@ proc renderHead*(prefs: Prefs; cfg: Config; req: Request; titleText=""; desc="";
|
||||||
link(rel="preload", type="image/png", href=bannerUrl, `as`="image")
|
link(rel="preload", type="image/png", href=bannerUrl, `as`="image")
|
||||||
|
|
||||||
for url in images:
|
for url in images:
|
||||||
let suffix = if "400x400" in url or url.endsWith("placeholder.png"): ""
|
let preloadUrl = if "400x400" in url: getPicUrl(url)
|
||||||
else: "?name=small"
|
else: getSmallPic(url)
|
||||||
let preloadUrl = getPicUrl(url & suffix)
|
|
||||||
link(rel="preload", type="image/png", href=preloadUrl, `as`="image")
|
link(rel="preload", type="image/png", href=preloadUrl, `as`="image")
|
||||||
|
|
||||||
let image = getUrlPrefix(cfg) & getPicUrl(url)
|
let image = getUrlPrefix(cfg) & getPicUrl(url)
|
||||||
|
|
|
@ -3,6 +3,14 @@ import strutils, strformat
|
||||||
import karax/[karaxdsl, vdom, vstyles]
|
import karax/[karaxdsl, vdom, vstyles]
|
||||||
import ".."/[types, utils]
|
import ".."/[types, utils]
|
||||||
|
|
||||||
|
const smallWebp* = "?name=small&format=webp"
|
||||||
|
|
||||||
|
proc getSmallPic*(url: string): string =
|
||||||
|
result = url
|
||||||
|
if "?" notin url and not url.endsWith("placeholder.png"):
|
||||||
|
result &= smallWebp
|
||||||
|
result = getPicUrl(result)
|
||||||
|
|
||||||
proc icon*(icon: string; text=""; title=""; class=""; href=""): VNode =
|
proc icon*(icon: string; text=""; title=""; class=""; href=""): VNode =
|
||||||
var c = "icon-" & icon
|
var c = "icon-" & icon
|
||||||
if class.len > 0: c = &"{c} {class}"
|
if class.len > 0: c = &"{c} {class}"
|
||||||
|
|
|
@ -7,14 +7,7 @@ import renderutils
|
||||||
import ".."/[types, utils, formatters]
|
import ".."/[types, utils, formatters]
|
||||||
import general
|
import general
|
||||||
|
|
||||||
const
|
const doctype = "<!DOCTYPE html>\n"
|
||||||
doctype = "<!DOCTYPE html>\n"
|
|
||||||
|
|
||||||
proc getSmallPic(url: string): string =
|
|
||||||
result = url
|
|
||||||
if "?" notin url and not url.endsWith("placeholder.png"):
|
|
||||||
result &= "?name=small"
|
|
||||||
result = getPicUrl(result)
|
|
||||||
|
|
||||||
proc renderMiniAvatar(user: User; prefs: Prefs): VNode =
|
proc renderMiniAvatar(user: User; prefs: Prefs): VNode =
|
||||||
let url = getPicUrl(user.getUserPic("_mini"))
|
let url = getPicUrl(user.getUserPic("_mini"))
|
||||||
|
@ -60,9 +53,8 @@ proc renderAlbum(tweet: Tweet): VNode =
|
||||||
tdiv(class="attachment image"):
|
tdiv(class="attachment image"):
|
||||||
let
|
let
|
||||||
named = "name=" in photo
|
named = "name=" in photo
|
||||||
orig = photo
|
small = if named: photo else: photo & smallWebp
|
||||||
small = if named: photo else: photo & "?name=small"
|
a(href=getOrigPicUrl(photo), class="still-image", target="_blank"):
|
||||||
a(href=getOrigPicUrl(orig), class="still-image", target="_blank"):
|
|
||||||
genImg(small)
|
genImg(small)
|
||||||
|
|
||||||
proc isPlaybackEnabled(prefs: Prefs; playbackType: VideoType): bool =
|
proc isPlaybackEnabled(prefs: Prefs; playbackType: VideoType): bool =
|
||||||
|
|
Loading…
Reference in a new issue