Skip to content

Commit

Permalink
fix: improve picsum placeholder image loading
Browse files Browse the repository at this point in the history
  • Loading branch information
ndom91 committed Aug 11, 2024
1 parent dc857db commit 85ca86e
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
if (bookmark.image) {
return `${PUBLIC_WORKER_URL}/img/s_260x144/${bookmark.image}`
} else {
return `${PUBLIC_WORKER_URL}/img/_/https://source.unsplash.com/random/260x144?sig=${bookmark.url}`
return `${PUBLIC_WORKER_URL}/img/_/https://picsum.photos/seed/${btoa(bookmark.url).substring(0, 16)}/256/144.webp`
}
})
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/lib/components/feed-row/FeedRow.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
if (feedEntry.feedMedia?.[0]?.href) {
return `${PUBLIC_WORKER_URL}/img/s_160x96/${feedEntry.feedMedia?.[0]?.href}`
} else {
return `${PUBLIC_WORKER_URL}/img/_/https://picsum.photos/seed/${encodeURIComponent(feedEntry.id)}/160/96.webp`
return `${PUBLIC_WORKER_URL}/img/_/https://picsum.photos/seed/${btoa(feedEntry.link).substring(0, 16)}/160/96.webp`
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
if (item.image) {
return `${PUBLIC_WORKER_URL}/img/s_256x144/${item.image}`
} else {
return `${PUBLIC_WORKER_URL}/img/_/https://picsum.photos/seed/${encodeURIComponent(item.id)}/256/144.webp`
return `${PUBLIC_WORKER_URL}/img/_/https://picsum.photos/seed/${btoa(item.url).substring(0, 16)}/256/144.webp`
}
})
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
if (item.feedMedia?.[0]?.href) {
return `${PUBLIC_WORKER_URL}/img/s_256x144/${item.feedMedia[0].href}`
} else {
return `${PUBLIC_WORKER_URL}/img/_/https://picsum.photos/seed/${encodeURIComponent(item.id)}/256/144.webp`
return `${PUBLIC_WORKER_URL}/img/_/https://picsum.photos/seed/${btoa(item.link).substring(0, 16)}/256/144.webp`
}
})
</script>
Expand Down

0 comments on commit 85ca86e

Please sign in to comment.