mirror of
https://github.com/zedeus/nitter.git
synced 2025-03-04 10:01:24 +00:00
Add lazy loading for images
This commit is contained in:
parent
b43bfc5d42
commit
7728899948
2 changed files with 5 additions and 7 deletions
|
@ -91,7 +91,7 @@ proc genDate*(pref, state: string): VNode =
|
||||||
|
|
||||||
proc genImg*(url: string; class=""): VNode =
|
proc genImg*(url: string; class=""): VNode =
|
||||||
buildHtml():
|
buildHtml():
|
||||||
img(src=getPicUrl(url), class=class, alt="")
|
img(src=getPicUrl(url), class=class, alt="", loading="lazy")
|
||||||
|
|
||||||
proc getTabClass*(query: Query; tab: QueryKind): string =
|
proc getTabClass*(query: Query; tab: QueryKind): string =
|
||||||
if query.kind == tab: "tab-item active"
|
if query.kind == tab: "tab-item active"
|
||||||
|
|
|
@ -10,9 +10,7 @@ import general
|
||||||
const doctype = "<!DOCTYPE html>\n"
|
const doctype = "<!DOCTYPE html>\n"
|
||||||
|
|
||||||
proc renderMiniAvatar(user: User; prefs: Prefs): VNode =
|
proc renderMiniAvatar(user: User; prefs: Prefs): VNode =
|
||||||
let url = getPicUrl(user.getUserPic("_mini"))
|
genImg(user.getUserPic("_mini"), class=(prefs.getAvatarClass & " mini"))
|
||||||
buildHtml():
|
|
||||||
img(class=(prefs.getAvatarClass & " mini"), src=url)
|
|
||||||
|
|
||||||
proc renderHeader(tweet: Tweet; retweet: string; pinned: bool; prefs: Prefs): VNode =
|
proc renderHeader(tweet: Tweet; retweet: string; pinned: bool; prefs: Prefs): VNode =
|
||||||
buildHtml(tdiv):
|
buildHtml(tdiv):
|
||||||
|
@ -92,10 +90,10 @@ proc renderVideo*(video: Video; prefs: Prefs; path: string): VNode =
|
||||||
tdiv(class="attachment video-container"):
|
tdiv(class="attachment video-container"):
|
||||||
let thumb = getSmallPic(video.thumb)
|
let thumb = getSmallPic(video.thumb)
|
||||||
if not video.available:
|
if not video.available:
|
||||||
img(src=thumb)
|
img(src=thumb, loading="lazy")
|
||||||
renderVideoUnavailable(video)
|
renderVideoUnavailable(video)
|
||||||
elif not prefs.isPlaybackEnabled(playbackType):
|
elif not prefs.isPlaybackEnabled(playbackType):
|
||||||
img(src=thumb)
|
img(src=thumb, loading="lazy")
|
||||||
renderVideoDisabled(playbackType, path)
|
renderVideoDisabled(playbackType, path)
|
||||||
else:
|
else:
|
||||||
let
|
let
|
||||||
|
@ -144,7 +142,7 @@ proc renderPoll(poll: Poll): VNode =
|
||||||
proc renderCardImage(card: Card): VNode =
|
proc renderCardImage(card: Card): VNode =
|
||||||
buildHtml(tdiv(class="card-image-container")):
|
buildHtml(tdiv(class="card-image-container")):
|
||||||
tdiv(class="card-image"):
|
tdiv(class="card-image"):
|
||||||
img(src=getPicUrl(card.image), alt="")
|
genImg(card.image)
|
||||||
if card.kind == player:
|
if card.kind == player:
|
||||||
tdiv(class="card-overlay"):
|
tdiv(class="card-overlay"):
|
||||||
tdiv(class="overlay-circle"):
|
tdiv(class="overlay-circle"):
|
||||||
|
|
Loading…
Reference in a new issue