Skip to content

Commit c3b2462

Browse files
committed
Blur nsfw images on cards
This was meant to do this already, but I missed it, so nsfw images were showing unblurred when the blur setting is on.
1 parent 97b7ebb commit c3b2462

File tree

4 files changed

+24
-6
lines changed

4 files changed

+24
-6
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Alexandrite",
3-
"version": "0.8.2",
3+
"version": "0.8.3",
44
"private": true,
55
"scripts": {
66
"dev": "vite dev",

src/lib/Image.svelte

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@
1818
.image-mode-thumbnail.blur:not(:hover) img {
1919
filter: blur(10px);
2020
}
21+
.image-mode-full.blur {
22+
// need to do this otherwise the blur overflows its container and goes all over the card
23+
display: block;
24+
overflow: hidden;
25+
26+
&:not(:hover) img {
27+
filter: blur(40px);
28+
}
29+
}
2130
img {
2231
width: 100%;
2332
}

src/lib/feeds/posts/previews/CardPostImage.svelte

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,22 @@
1616
}
1717
</style>
1818

19-
<div class="card-image" class:nsfw={postView.post.nsfw || postView.community.nsfw}>
19+
<div class="card-image" class:nsfw={isNsfw}>
2020
{#if (postView.post.nsfw || postView.community.nsfw) && $nsfwImageHandling === 'HIDE' && !showAnyway}
2121
<div class="card-image-placeholder">
2222
<button class="tertiary" on:click|stopPropagation={() => (showAnyway = true)}> Show NSFW </button>
2323
</div>
2424
{:else if postAssertions.imageSrc}
25-
<!-- not passing nsfw, this component handles it otherwise we'd have nested buttons -->
26-
<Image src={postAssertions.imageSrc} full resizable={false} lazy={false} loadingHeight="20rem" />
25+
<!-- not passing nsfw when handling='show' this component handles it otherwise we'd have nested buttons,
26+
but we need to still tell it when it needs to blur otherwise you see unblurred nsfw content -->
27+
<Image
28+
src={postAssertions.imageSrc}
29+
full
30+
resizable={false}
31+
lazy={false}
32+
loadingHeight="20rem"
33+
nsfw={$nsfwImageHandling === 'BLUR' && isNsfw}
34+
/>
2735
{/if}
2836
</div>
2937

@@ -39,4 +47,5 @@
3947
4048
let showAnyway = false;
4149
$: postAssertions = makePostAssertions(postView);
50+
$: isNsfw = postView.post.nsfw || postView.community.nsfw;
4251
</script>

0 commit comments

Comments
 (0)