mirror of
https://github.com/zedeus/nitter.git
synced 2025-03-13 22:32:41 +00:00
Lazy load images
This commit is contained in:
parent
0610f7b890
commit
608c3ca8df
2 changed files with 13 additions and 10 deletions
|
@ -82,7 +82,7 @@ proc genDate*(pref, state: string): VNode =
|
|||
|
||||
proc genImg*(url: string; class=""): VNode =
|
||||
buildHtml():
|
||||
img(src=getPicUrl(url), class=class, alt="")
|
||||
img(src=getPicUrl(url), class=class, alt="", loading="lazy", decoding="async")
|
||||
|
||||
proc getTabClass*(query: Query; tab: QueryKind): string =
|
||||
result = "tab-item"
|
||||
|
|
|
@ -16,7 +16,7 @@ proc getSmallPic(url: string): string =
|
|||
proc renderMiniAvatar(user: User; prefs: Prefs): VNode =
|
||||
let url = getPicUrl(user.getUserPic("_mini"))
|
||||
buildHtml():
|
||||
img(class=(prefs.getAvatarClass & " mini"), src=url)
|
||||
img(class=(prefs.getAvatarClass & " mini"), src=url, loading="lazy")
|
||||
|
||||
proc renderHeader(tweet: Tweet; retweet: string; prefs: Prefs): VNode =
|
||||
buildHtml(tdiv):
|
||||
|
@ -97,13 +97,9 @@ proc renderVideo*(video: Video; prefs: Prefs; path: string): VNode =
|
|||
tdiv(class="gallery-video" & container):
|
||||
tdiv(class="attachment video-container"):
|
||||
let thumb = getSmallPic(video.thumb)
|
||||
if not video.available:
|
||||
img(src=thumb)
|
||||
renderVideoUnavailable(video)
|
||||
elif not prefs.isPlaybackEnabled(playbackType):
|
||||
img(src=thumb)
|
||||
renderVideoDisabled(playbackType, path)
|
||||
else:
|
||||
let canPlay = prefs.isPlaybackEnabled(playbackType)
|
||||
|
||||
if video.available and canPlay:
|
||||
let
|
||||
vidUrl = video.getVidVariant(playbackType).url
|
||||
source = if prefs.proxyVideos: getVidUrl(vidUrl)
|
||||
|
@ -119,6 +115,13 @@ proc renderVideo*(video: Video; prefs: Prefs; path: string): VNode =
|
|||
verbatim "<div class=\"video-overlay\" onclick=\"playVideo(this)\">"
|
||||
tdiv(class="overlay-circle"): span(class="overlay-triangle")
|
||||
verbatim "</div>"
|
||||
else:
|
||||
img(src=thumb, loading="lazy", decoding="async")
|
||||
if not canPlay:
|
||||
renderVideoDisabled(playbackType, path)
|
||||
else:
|
||||
renderVideoUnavailable(video)
|
||||
|
||||
if container.len > 0:
|
||||
tdiv(class="card-content"):
|
||||
h2(class="card-title"): text video.title
|
||||
|
@ -156,7 +159,7 @@ proc renderPoll(poll: Poll): VNode =
|
|||
proc renderCardImage(card: Card): VNode =
|
||||
buildHtml(tdiv(class="card-image-container")):
|
||||
tdiv(class="card-image"):
|
||||
img(src=getPicUrl(card.image), alt="")
|
||||
img(src=getPicUrl(card.image), alt="", loading="lazy")
|
||||
if card.kind == player:
|
||||
tdiv(class="card-overlay"):
|
||||
tdiv(class="overlay-circle"):
|
||||
|
|
Loading…
Reference in a new issue