1 parent
2902f30327
commit
e259ed4582
7 files changed
+142
-47
No files matched your search
@@ -8,6 +8,9 @@
|
||||
import PostMeta from '$lib/components/lemmy/post/PostMeta.svelte'
|
||||
import { Material, toast } from 'mono-svelte'
|
||||
import Markdown from '$lib/components/markdown/Markdown.svelte'
|
||||
import ExpandableImage from '$lib/components/ui/ExpandableImage.svelte'
|
||||
import { bestImageURL, postLink } from '$lib/components/lemmy/post/helpers.js'
|
||||
import Empty from '$lib/components/helper/Empty.svelte'
|
||||
|
||||
export let post: PostView
|
||||
export let actions: boolean = true
|
||||
@@ -54,36 +57,42 @@
|
||||
{#if !$userSettings.showCompactPosts}
|
||||
{#if isImage(post.post.url)}
|
||||
<!--disabled preloads here since most people will hover over every image while scrolling-->
|
||||
<a
|
||||
href="/post/{getInstance()}/{post.post.id}"
|
||||
class="self-start overflow-hidden z-10 relative bg-slate-200 dark:bg-zinc-800 rounded-md max-w-full"
|
||||
data-sveltekit-preload-data="off"
|
||||
aria-label={post.post.name}
|
||||
<svelte:component
|
||||
this={$userSettings.expandImages ? ExpandableImage : Empty}
|
||||
url={bestImageURL(post.post, false, 2048)}
|
||||
>
|
||||
<picture
|
||||
class="rounded-md overflow-hidden max-h-[min(50vh,500px)] w-full max-w-full"
|
||||
<svelte:element
|
||||
this={$userSettings.expandImages ? 'div' : 'a'}
|
||||
href={postLink(post.post)}
|
||||
class="self-start overflow-hidden z-10 relative bg-slate-200 dark:bg-zinc-800 rounded-md max-w-full"
|
||||
data-sveltekit-preload-data="off"
|
||||
aria-label={post.post.name}
|
||||
>
|
||||
<source
|
||||
srcset="{post.post.url}?thumbnail=256&format=webp"
|
||||
media="(max-width: 256px)"
|
||||
/>
|
||||
<source
|
||||
srcset="{post.post.url}?thumbnail=512&format=webp"
|
||||
media="(max-width: 512px)"
|
||||
/>
|
||||
<!-- svelte-ignore a11y-missing-attribute -->
|
||||
<img
|
||||
src="{post.post.url}?thumbnail=512&format=webp"
|
||||
loading="lazy"
|
||||
class="max-w-full object-cover rounded-md max-h-[80vh] h-auto z-30 opacity-0 transition-opacity duration-300"
|
||||
class:opacity-100={loaded}
|
||||
width={512}
|
||||
height={300}
|
||||
class:blur-3xl={post.post.nsfw && $userSettings.nsfwBlur}
|
||||
on:load={() => (loaded = true)}
|
||||
/>
|
||||
</picture>
|
||||
</a>
|
||||
<picture
|
||||
class="rounded-md overflow-hidden max-h-[min(50vh,500px)] w-full max-w-full"
|
||||
>
|
||||
<source
|
||||
srcset={bestImageURL(post.post, false, 512)}
|
||||
media="(max-width: 256px)"
|
||||
/>
|
||||
<source
|
||||
srcset={bestImageURL(post.post, false, 512)}
|
||||
media="(max-width: 512px)"
|
||||
/>
|
||||
<!-- svelte-ignore a11y-missing-attribute -->
|
||||
<img
|
||||
src={bestImageURL(post.post, false, 1024)}
|
||||
loading="lazy"
|
||||
class="max-w-full object-cover rounded-md max-h-[80vh] h-auto z-30 opacity-0 transition-opacity duration-300"
|
||||
class:opacity-100={loaded}
|
||||
width={512}
|
||||
height={300}
|
||||
class:blur-3xl={post.post.nsfw && $userSettings.nsfwBlur}
|
||||
on:load={() => (loaded = true)}
|
||||
/>
|
||||
</picture>
|
||||
</svelte:element>
|
||||
</svelte:component>
|
||||
{:else if post.post.url}
|
||||
<PostLink
|
||||
url={post.post.url}
|
||||
@@ -113,23 +122,29 @@
|
||||
</div>
|
||||
{#if $userSettings.showCompactPosts && (post.post.thumbnail_url || isImage(post.post.url))}
|
||||
<div class="flex-none w-24 h-24">
|
||||
<a href="/post/{getInstance()}/{post.post.id}">
|
||||
{#if post.post.thumbnail_url}
|
||||
<!-- svelte-ignore a11y-missing-attribute -->
|
||||
<img
|
||||
src="{post.post.thumbnail_url}?thumbnail=256&format=webp"
|
||||
loading="lazy"
|
||||
class="object-cover bg-slate-100 rounded-md h-24 w-24 border border-slate-200 dark:border-zinc-700"
|
||||
/>
|
||||
{:else}
|
||||
<!-- svelte-ignore a11y-missing-attribute -->
|
||||
<img
|
||||
src="{post.post.url}?thumbnail=256&format=webp"
|
||||
loading="lazy"
|
||||
class="object-cover bg-slate-100 rounded-md h-24 w-24 border border-slate-200 dark:border-zinc-700"
|
||||
/>
|
||||
{/if}
|
||||
</a>
|
||||
{#if !$userSettings.expandImages || (post.post.thumbnail_url && !isImage(post.post.url))}
|
||||
<a href={postLink(post.post)}>
|
||||
{#if post.post.thumbnail_url}
|
||||
<!-- svelte-ignore a11y-missing-attribute -->
|
||||
<img
|
||||
src={bestImageURL(post.post, true)}
|
||||
loading="lazy"
|
||||
class="object-cover bg-slate-100 rounded-md h-24 w-24 border border-slate-200 dark:border-zinc-700"
|
||||
/>
|
||||
{/if}
|
||||
</a>
|
||||
{:else}
|
||||
<ExpandableImage url={bestImageURL(post.post, false)}>
|
||||
{#if post.post.thumbnail_url}
|
||||
<!-- svelte-ignore a11y-missing-attribute -->
|
||||
<img
|
||||
src={bestImageURL(post.post, true)}
|
||||
loading="lazy"
|
||||
class="object-cover bg-slate-100 rounded-md h-24 w-24 border border-slate-200 dark:border-zinc-700"
|
||||
/>
|
||||
{/if}
|
||||
</ExpandableImage>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user