From 9c8c2cbe8868c8252c825b169dec8d3c40d3143a Mon Sep 17 00:00:00 2001 From: Zed Date: Sun, 7 Jun 2020 07:57:32 +0200 Subject: [PATCH] Use small image version for preview to save memory --- src/views/profile.nim | 5 +++-- src/views/tweet.nim | 10 ++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/views/profile.nim b/src/views/profile.nim index 3e1b260..57a0511 100644 --- a/src/views/profile.nim +++ b/src/views/profile.nim @@ -16,7 +16,7 @@ proc renderProfileCard*(profile: Profile; prefs: Prefs): VNode = tdiv(class="profile-card-info"): let url = getPicUrl(profile.getUserPic()) a(class="profile-card-avatar", href=url, target="_blank"): - genImg(profile.getUserpic("_200x200")) + genImg(profile.getUserpic("_400x400")) tdiv(class="profile-card-tabs-name"): linkUser(profile, class="profile-card-fullname") @@ -72,8 +72,9 @@ proc renderPhotoRail(profile: Profile; photoRail: PhotoRail): VNode = tdiv(class="photo-rail-grid"): for i, photo in photoRail: if i == 16: break + let col = if photo.color.len > 0: photo.color else: "#161616" a(href=(&"/{profile.username}/status/{photo.tweetId}#m"), - style={backgroundColor: photo.color}): + style={backgroundColor: col}): genImg(photo.url & (if "format" in photo.url: "" else: ":thumb")) proc renderBanner(profile: Profile): VNode = diff --git a/src/views/tweet.nim b/src/views/tweet.nim index e1dc01e..5a9ce79 100644 --- a/src/views/tweet.nim +++ b/src/views/tweet.nim @@ -38,10 +38,12 @@ proc renderAlbum(tweet: Tweet): VNode = tdiv(class="gallery-row", style={marginTop: margin}): for photo in photos: tdiv(class="attachment image"): - var url = photo - if "=orig" notin url: url &= "?name=orig" - a(href=getPicUrl(url), class="still-image", target="_blank"): - genImg(photo) + let + named = "name=" in photo + orig = if named: photo else: photo & "?name=orig" + small = if named: photo else: photo & "?name=small" + a(href=getPicUrl(orig), class="still-image", target="_blank"): + genImg(small) proc isPlaybackEnabled(prefs: Prefs; video: Video): bool = case video.playbackType